Waqar ahmad
Waqar ahmad

Reputation: 139

Getting data from Json url using CURL Returning NULL

i have a JSON link , i want to get data from it but it is returning NULL.

Code:

$url = 'https://cheddargetter.com/json/customers/search/orderBy/id/orderByDirection/asc/perPage/100/';

//  Initiate curl
$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);
// Closing
curl_close($ch);

// Will dump a beauty json :3
//var_dump(json_decode($result, true));                                                                                              

echo '<pre>abc'. print_r($result) . '</pre>';

Upvotes: 0

Views: 319

Answers (1)

Red Acid
Red Acid

Reputation: 227

your code looks correct. the problem is the url. I guess it ask for authentication to get the json data.

https://cheddargetter.com/?fwd=%2Fjson%2Fcustomers%2Fsearch%2ForderBy%2Fid%2ForderByDirection%2Fasc%2FperPage%2F100%2F#login 

Upvotes: 1

Related Questions