我有这段代码,我想在 curl 响应中获取“项目”的所有数据,当我使用浏览器访问 URL 时,它会显示所有“项目”,但是使用这段代码,curl 响应正在工作,但是“items”为空,代码如下:
$eop = 0;
$newest = 0;
while($eop == 0) {
$url='https://shopee.ph/api/v2/search_items/?by=ctime&limit=30&match_id=49133756&newest=0&order=desc&page_type=shop&version=2';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
$http = curl_getinfo($ch, CURLINFO_HTTP_CODE);
print_r($response);
curl_close($ch);
if ($http == 200) {
$products = @json_decode($response, TRUE);
$items = $products['items'];
if (count($items) > 1 ) {
foreach ($items as $item) {
$id = $item['itemid'];
echo $id . '<br>';
}
} else {
$eop=1;
}
}
$newest = $newest + 30;
}
这是回应:
{"show_disclaimer":null,"query_rewrite":null,"adjust":null,"version":"b1c94828d525e526ff969f451cc3ac33","algorithm":null,"total_count":null,"error":null,"total_ads_count":null,"nomore":null,"price_adjust":null,"json_data":null,"suggestion_algorithm":null,"items":null,"reserved_keyword":null,"hint_keywords":null}
慕田峪7331174