0

I am trying to create a simple script that will retrieve the last 5 feeds for a twitter user (in this instance the BBC)

It runs okay locally on my development server but once I upload this to a live site I get the following error:

Warning: file_get_contents(https://api.twitter.com/1/statuses/user_timeline.json?include_entities=true&include_rts=true&screen_name=bbc&count=5): failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request in ....

Does anyone know why this doesn't work on my live server (but fine on my dev server?)

Zabs
  • 13,852
  • 45
  • 173
  • 297

1 Answers1

1

As mentioned in file_get_contents throws 400 Bad Request error PHP, you may be better using curl instead of file_get_contents due to its improved error handling - this may provide you with another clue.

Community
  • 1
  • 1
Celtis
  • 26
  • 4
  • I've tried this but just get a returned value of NULL. Any ideas? http://phpfiddle.org/main/code/uuw-b5c – Zabs May 14 '13 at 13:14
  • First thing that stands out is that you're missing a _?_ between `user_timeline.json` and `include_entities=true`. – Celtis May 14 '13 at 13:23
  • Done some additional research - as of Twitter API v1.1 they will no longer be accepting unauthorised requests so i'll need to use oAuth or something similar - this link seems the best method http://stackoverflow.com/questions/12916539/simplest-php-example-retrieving-user-timeline-with-twitter-api-version-1-1 – Zabs May 14 '13 at 13:31
  • Cheers@celtis Got it working.. will post code here later for anyone else having a similar problem – Zabs May 14 '13 at 14:33