I\'m trying to use file_get_contents()
to grab a twitter feed, however I\'m getting the following warning:
failed to open stream: HTTP request
Most probably, your server have mod_security enabled. Add the below lines in your .htaccess after any existing rules and then try to see the issue is still there, after that addition.
<IfModule mod_security.c>
SecFilterScanPost
</IfModule>
You should use the PHP cURL extension if it's available, as it's many times faster, more powerful, and easier to debug. Here is an example that does the same thing you were trying:
function curl($url) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
$feed = 'http://twitter.com/statuses/user_timeline.rss?screen_name=google&count=6';
$tweets = curl($feed);