【发布时间】:2015-07-19 03:44:44
【问题描述】:
我正在尝试像这样向 coinbase api 发出请求
$url = "https://api.gdax.com/products/BTC-USD/candles?start=".date($format,$starting_date)."&end=".date($format,$ending_date)."&granularity=".$granularity;
然后我在file_get_contents($url) 中传递它,但它给了我一个错误
file_get_contents(https://api.gdax.com/products/BTC-USD/candles?start=2015-05-07&end=2015-05-08&granularity=900):打开流失败:HTTP 请求失败! HTTP/1.1 400 错误请求。
问题当然是当 '&' 变成 '&' 时。
【问题讨论】:
-
您确定这是问题所在吗?因为直接访问该网址可以正常工作。
-
也许不是。但还有什么可能是它没有返回文件内容而是错误的原因。
-
这可能会回答你的问题:stackoverflow.com/questions/3710147/…
-
PHP 7.0 中似乎有一个错误导致有效的 URL 字符串出现这种情况。切换到 7.1 即可解决。
标签: php url file-get-contents url-encoding ampersand