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 Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.