tags:

views:

51

answers:

2

I have to access the following url in my PHP code .

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. My query is " how to retrieve the response in php code ".

Please provide a code sample for this as i'm quite new in this area of php !

+3  A: 

Use PHP JSON junctions json_decode and json_encode http://php.net/manual/en/function.json-encode.php

$json = file_get_contents("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");

$myArr = json_decode($json);

var_dump($myArr);
Lizard
+2  A: 
$json = file_get_contents("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");

$response = json_decode( stripslashes($json) );

should work quite well

helle