我在网址上使用Zend HTTP时遇到问题:
$bestBuyClient = new Zend_Http_Client('https://api.bestbuy.com/v1/products(search=pizza&salePrice>10&salePrice<15)?apiKey=MyKeyHere&page=1&numItems=10&format=json&show=sku&name&productId&type®ularPrice&salePrice&upc&modelNumber&image&largeFrontImage&mediumImage&thumbnailImage&largeImage&shortDescription&longDescription');
$response = $bestBuyClient->request();
$json="";
if($response->isSuccessful()){
$jsonTxt=$response->getBody();
$json = @json_decode($jsonTxt,true);
}
$jsonProducts=$json;
return $jsonProducts;
出于某种原因,这给了我一个错误:
Invalid URI supplied
这个特定的网址错了吗?
编辑:在PostMan或浏览器请求中发送正确的数据。
答案 0 :(得分:1)
你可以改变:
$bestBuyClient = new Zend_Http_Client('https://api.bestbuy.com/v1/products(search=pizza&salePrice>10&salePrice<15)?apiKey=MyKeyHere&page=1&numItems=10&format=json&show=sku&name&productId&type®ularPrice&salePrice&upc&modelNumber&image&largeFrontImage&mediumImage&thumbnailImage&largeImage&shortDescription&longDescription');
$response = $bestBuyClient->request();
要
$shoppableClient = new Zend_Http_Client(sprintf('https://api.bestbuy.com/v1/products'."%s?%s", urlencode('(search=pizza&salePrice>10&salePrice<15)'), 'apiKey=MyKeyHere&page=1&numItems=10&format=json&show=sku&name&productId&type®ularPrice&salePrice&upc&modelNumber&image&largeFrontImage&mediumImage&thumbnailImage&largeImage&shortDescription&longDescription'));
如果有效,请告诉我。)。