1

I need to fetch data from an API using curl. As per the manual given the curl command should be like this

curl --user {YOUR_CLIENT_ID}:{YOUR_CLIENT_SECRET} https://www.udemy.com/api-2.0/courses

Now while passing this command in pUTTY I am getting response and the data is displaying correctly but how to use this in a PHP page...am quiet new with cURL so any suggestion would help me a lot.

Thanks in advance

user3305327
  • 897
  • 4
  • 18
  • 34
  • possible duplicate of [How to use cURL to get jSON data and decode the data?](http://stackoverflow.com/questions/16700960/how-to-use-curl-to-get-json-data-and-decode-the-data) – machineaddict May 27 '15 at 09:29

1 Answers1

1
$ch = curl_init();
// Disable SSL verification
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
// Will return the response, if false it print the response
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Set the url
curl_setopt($ch, CURLOPT_URL,$url);
// Execute
$result=curl_exec($ch);
// Will dump a beauty json <3
$fr=json_decode($result, true);
abh
  • 1,189
  • 2
  • 14
  • 30
  • @Babar...thanks for so prompt answer...ok I can fetch the data but can you please help me on how to fetch the title, url and price from these data for each course – user3305327 May 27 '15 at 09:09
  • use var_dump() to check structure of array and then get your desired data – abh May 27 '15 at 09:10