2016-12-01 10 views
0

GitHubリポジトリをリストしたいと思います。403リポジトリ検索APIを使用する際に禁止

Warning: file_get_contents(https://api.github.com/search/repositories?q=user:<username>): failed to open stream: HTTP request failed! HTTP/1.0 403 Forbidden

My機能は次のとおりです。:

public function repoListAction() 
{ 
    $repositories = json_decode(file_get_contents('https://api.github.com/search/repositories?q=user:<put your username here>'), true); 

    return $this->render('full/repolist.html.twig', array(
     'repositories' => $repositories, 
    )); 
} 

答えて

1

GitHub's API documentationリストにはいくつかの理由私はAPIのページをロードしようとすると、私は403エラーを取得するとき、私はしかし、私のブラウザにJSONを表示することができます403応答コード。認証されていないクエリのGithubのレート制限に達している可能性があります。これは、X-RateLimit-LimitX-RateLimit-Remaining、およびX-RateLimit-Resetヘッダーを確認することで確認できます。あなたの要求にUser-Agentヘッダーがないかもしれません。

正確なエラーと推論の詳細が含まれる応答の本文を確認することで、正確な問題を確認できます。

関連する問題