- 2010/6/15 火曜日 0:09:26
- インターネット
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:
- 新しい: Tokyo CGM Night 8 に行ってきた!
- 古い: はやぶさ帰還。
コメント: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 出たよメモ [...]