Zend HTTP Client提供的URI无效?

时间:2017-05-01 11:02:10

标签: php url zend-framework

我在网址上使用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&regularPrice&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或浏览器请求中发送正确的数据。

1 个答案:

答案 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&regularPrice&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&regularPrice&salePrice&upc&modelNumber&image&largeFrontImage&mediumImage&thumbnailImage&largeImage&shortDescription&longDescription'));

如果有效,请告诉我。)。