ホーム > インターネット > twitter api叩いたら 400 Bad Request 出たよメモ

twitter api叩いたら 400 Bad Request 出たよメモ

Amazon EC2環境でTwitterAPI叩いてて、このエラーでハマりました。

failed to open stream: HTTP request failed! HTTP/1.1 400 Bad Request


リクエスト回数制限は超えてないし、
コマンドラインでwgetするとちゃんと取得できるし、
同じURLをブラウザやローカルPCから呼ぶとちゃんと値が戻るのに、

phpでfile_get_contents()するとエラーになる。。

で、いろいろ調べてたらapiwikiにこんなの見つけました。

Applications must have a meaningful and unique User Agent when using this method. A HTTP Referrer is expected but not required. Search traffic that does not include a User Agent will be rate limited to fewer API calls per hour than applications including a User Agent string.

Twitter Search API Method: search

ということで、

ini_set(‘user_agent’, ‘User-Agent: xxx’);

これを追加したら解決しましたよ。

ほっ

Similar Posts:

コメント:0

コメントフォーム
入力した情報を記憶する

トラックバック:2

この記事のトラックバック URL
http://www.ogaworks.com/archives/2920/trackback
トラックバックの送信元リスト
twitter api叩いたら 400 Bad Request 出たよメモ - ogaworks より
pingback - twitter API 制限について より 2010/6/23 水曜日

[...] http://www.ogaworks.com/archives/2920 [...]

pingback - PHPでTwitter最新のつぶやきを表示する方法 | Johnnnnny.com より 2010/9/17 金曜日

[...] 参考サイトはこちらogaworks – twitter api叩いたら 400 Bad Request 出たよメモ [...]

ホーム > インターネット > twitter api叩いたら 400 Bad Request 出たよメモ

検索
フィード
メタ情報

ページの上部に戻る