0

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>'; 

1 Answer 1

1

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

5 Comments

but this link is generated by ChadderGetter itself
I agree. If you access to that URL through the browser, it should return JSON, instead, it redirects to their website. It means some kind of validation like an API key is missing.
how to authenticate in this link?
I haven't found any way to Authenticate using this link
cheddargetter.com/developers#format - it uses HTTP Basic Authentication . Just google on how to do that using php/Curl

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.