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

1

1 Answer 1

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);
Sign up to request clarification or add additional context in comments.

2 Comments

@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
use var_dump() to check structure of array and then get your desired data

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.