更新时间:2023-12-06 08:08:22
使用 curl_setopt($ ch,CURLOPT_RETURNTRANSFER,true);
卷曲并通过 json_decode()
...传递 true
。
Use curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
in your curl and pass true
with json_decode()
....
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "affiliate-feeds.snapdeal.com/feed/api/order?startDate=2016-01-01&endDate=2016-05-03&status=approved");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt(
$ch, CURLOPT_HTTPHEADER,
array(
'Snapdeal-Affiliate-Id:'.$affiliateId,
'Snapdeal-Token-Id:'.$token,
'Accept:application/json'
)
);
$response = curl_exec($ch);
curl_close($ch);
// work with $response here:
$jsonData = json_decode($response,true);
Mage::log($jsonData['productDetails'][0]['product']);
这将输出:
Philips QT4000 Trimmer Black