开发者

How to retrieve & use the JSON response of website in PHP?

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 !


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


$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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜