Problem with twitter feed

software development



I’m having problems with a twitter feed in a website hosted in Dreamhost.
I made an update in June to include a feed from twitter in the main page. Recently, can’t precise exactly when, the feed stop working and this error message is shown:

Warning: file_get_contents( [function.file-get-contents]: failed to open stream: HTTP request failed! in /home/domain/include/twitter-func.php on line 60

I’m using the twitter feed code from here.
I’m also tried the alternatives described here using cURL but without success (no feed is returned).

Anyone can help?
Thanks in advance.


Had the same problem, never really found an answer until some months later I installed the wordpress plugin “TwitterTools” and it seemed to fix everything and then some…

I followed their directions of obtaining a the appropriate keys and tokens directly from twitter’s developers page:

Hope this helps. I don’t recall the steps but it was pretty straight forward. Happy to look into this more if the steps are not clear




I am not sure what you are trying to do, but I made this for one of my sites to display a users (my) twitter feed:

class Twitter{
protected $twitURL = ‘’;
protected $xml;
public function __construct(){

public function loadUsersTimeline($user, $max = 10){
	$this->twitURL .= 'statuses/user_timeline.xml?screen_name='.$user.'&count='.$max;
	$ch = curl_init();
	curl_setopt($ch, CURLOPT_URL, $this->twitURL);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
	$this->xml = curl_exec($ch);
public function getTimelineArray(){
	return simplexml_load_string($this->xml);
public function formatTweet($tweet){
	$tweet = preg_replace("/@(.+?)(\h|\W)/", "<a href=\"!/$1\">@$1</a>$2", $tweet);
	return $tweet;


[php]include ‘Twitter.php’;
$twitter = new Twitter();
$twitter->loadUsersTimeline(TWITTER_SCREEN_NAME, 200);
$timeline = $twitter->getTimelineArray();
foreach($timeline->status as $status){
echo ‘



I’ll try it and post the results as soon as possible.