我正在尝试获取关键字的搜索产品
我的代码:
$searchquery = "ipod";
$api_endpoint = "http://api.walmartlabs.com/v1/search";
$postfields = "apiKey=". $appid ."&query=" . $searchquery;
//$postfields = array('apiKey' => $appid, 'query' => $searchquery);
$connection = curl_init();
curl_setopt($connection, CURLOPT_URL, $api_endpoint);
curl_setopt($connection, CURLOPT_SSL_VERIFYPEER, false);
//curl_setopt($connection, CURLOPT_SSL_VERIFYHOST, 0);
//curl_setopt($connection, CURLOPT_HTTPHEADER, $headers);
curl_setopt($connection, CURLOPT_POST, true);
curl_setopt($connection, CURLOPT_POSTFIELDS, $postfields);
curl_setopt($connection, CURLOPT_HEADER, true);
//curl_setopt($connection, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($connection, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($connection);
curl_close($connection);
print_r($api_endpoint);
print_r($response);
当我进入浏览器并访问 api.walmartlabs.com/v1/search?apiKey={appid}&query=ipod 时,它会显示结果,但是当我尝试使用 curl 时,它会显示“未找到操作”
这是屏幕截图
任何帮助,将不胜感激。