I'm trying to call eBay's Shopping API using PHP and cURL and returning the response in JSON format. It works when I put the URL in the browser directly but it doesn't within PHP. I don't want to work with XML. JSON is easier. Any suggestions?
$Url ="http://open.api.ebay.com/shopping?callname=GetMultipleItems&responseencoding=JSON&appid=MyAppId&siteid=0&version=525&ItemID=290585620456,290683575886&IncludeSelector=Details,ShippingCosts,Variations";
//check if you have curl loaded
if(!function_exists("curl_init")) die("cURL extension is not installed");
$ch=curl_init($Url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$r=curl_exec($ch);
curl_close($ch);
var_dump($r);
you should use
json_encode($response_string);
this will parse the response string into json object.
if you want basic array instead of json object, then use
json_decode($responce_str, true);
this will return an associative array.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.