所以这似乎是一个常见的错误,但我已经尝试了一切,但它不起作用!
我的代码目前如下所示:
$apikey = "XXXXXXXXX";
$search_url = "https://www.googleapis.com/shopping/search/v1/public/products?key=$apikey&country=US&q=$item_title&restrictBy=gtin&alt=json";
$response = file_get_contents($search_url);
我已经尝试了从 urldecode 到 html_entity_decode/encode 到几乎所有我能找到的解决方案,但仍然得到相同的错误:
file_get_contents(https://www.googleapis.com/shopping/search/v1/public/products?key=XXXXX&country=US&q=THESTRING&restrictBy=gtin&alt=json) failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request
如您所见,我得到的是 &s 而不是普通的 ol' & (&)
我记得有一个类似的问题,问题只是我在字符串的开头没有“http://”。但正如你所看到的,这里的情况并非如此。
谢谢!