naik.apoorv Posted June 10, 2010 Share Posted June 10, 2010 I have to get the data from the url https://test.httpapi.com/api/domains/available.json?auth-userid=0&auth-password=password&domain-name=domain&tlds=com&tlds=info&tlds=org&tlds=net&suggest-alternative=true The above url returns a JSON response when proper parameters are used . Can anyone suggest a portion of code that can handle this problem ?? also the above url can return an xml response if the url used is https://test.httpapi.com/api/domains/available.xml?auth-userid=0&auth-password=password&domain-name=domain&tlds=com&tlds=info&tlds=org&tlds=net&suggest-alternative=true also can any1 provide a way of handling this . I m quite new to php and in need of help Link to comment https://forums.phpfreaks.com/topic/204436-bhow-to-retrieve-the-json-response-from-a-urlb/ Share on other sites More sharing options...
kenrbnsn Posted June 10, 2010 Share Posted June 10, 2010 Use file_get_contents to retrieve the JSON output and json_decode to decode it. <?php $json = file_get_contents('https://test.httpapi.com/api/domains/available.xml?auth-userid=0&auth-password=password&domain-name=domain&tlds=com&tlds=info&tlds=org&tlds=net&suggest-alternative=true'); $ary = json_decode($json,true); echo '<pre>' . print_r($ary,true) . '</pre>'; //show what's in the resultant array ?> Ken Link to comment https://forums.phpfreaks.com/topic/204436-bhow-to-retrieve-the-json-response-from-a-urlb/#findComment-1070559 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.