Laravel Guzzle错误——cURL错误7:未能连接到api.github.com:80;连接超时
我试图通过laravel中的http请求获取github用户的详细信息 我用的是套装Guzzle。 我的控制器如下所示Laravel Guzzle错误——cURL错误7:未能连接到api.github.com:80;连接超时,curl,laravel-4,github-api,guzzle,Curl,Laravel 4,Github Api,Guzzle,我试图通过laravel中的http请求获取github用户的详细信息 我用的是套装Guzzle。 我的控制器如下所示 public function apiProject() { $client = new \GuzzleHttp\Client(); $response = $client->get('http://api.github.com/users/jishadp369'); dd($response->getBody()); } 当我在浏览
public function apiProject()
{
$client = new \GuzzleHttp\Client();
$response = $client->get('http://api.github.com/users/jishadp369');
dd($response->getBody());
}
当我在浏览器中指向路线时,浏览器加载一些时间并抛出错误,如
cURL error 7: Failed connect to api.github.com:80; Connection timed out
我尝试在终端与卷曲,我可以得到很好的结果
在Firebug->Net中:显示500个内部服务器错误
我怎样才能解决这个问题
谢谢
//输出JSON解码数据
$client = new GuzzleHttp\Client();
$response = $client->get('http://guzzlephp.org');
$res = $client->get('https://api.github.com/users/jishadp369');
echo $res->getStatusCode();
// "200"
echo $res->getHeader('content-type');
// 'application/json; charset=utf8'
echo $res->getBody();
// {"type":"User"...'
var_export($res->json());