0
嘗試使用使用Buzz了捲曲/的file_get_contents在我的Symfony應用程序從檢索數據一樣東西,你可以在這裏看到:403呼叫api.weather.gov使用Buzz了客戶端瓦特/ HTTPS
https://api.weather.gov/points/44.3537,-73.8636/forecast/hourly
不管什麼,我似乎得到一個403禁止錯誤,我想知道如果有人有任何建議?
$location = sprintf(
'/points/%f,%f/forecast/hourly', $this->latitude, $this->longitude
);
$request = new Request('GET', $location, 'https://api.weather.gov');
$response = new Response();
try {
$this->httpClient->send($request, $response);
} catch (\Exception $e) {
throw new ServiceResponseException('Failed to send Request', 0, $e);
}
if (!$response->isSuccessful()) {
throw new ServiceResponseException('Unsuccessful Response', $response->getStatusCode());
}
return $response->getContent();
在巴斯」 FileGetContents類
$url = $request->getHost().$request->getResource();
$ URL計算結果爲: https://api.weather.gov/points/44.353700,-73.863600/forecast/hourly
相同的捲曲度
頁眉返回
Array ([0] => HTTP/1.1 403 Forbidden [1] => Server: AkamaiGHost [2] => Mime-Version: 1.0 [3] => Content-Type: text/html [4] => Content-Length: 334 [5] => Expires: Thu, 13 Apr 2017 14:15:56 GMT [6] => Date: Thu, 13 Apr 2017 14:15:56 GMT [7] => Connection: close)
向我們顯示您的代碼 – ATechGuy
對不起@ATechGuy,剛剛添加了我使用的一個blurb – jackie