Getting Twitter tweets

Ask about a PHP problem here.
Post Reply
Fidbeck
Posts: 147
Joined: Tue Sep 25, 2012 11:40 pm

Getting Twitter tweets

Post by Fidbeck »

I can't work around this code
[syntax=php]
<?php
$username = "";
$password = "";
$timeline = curl_init("http://api.twitter.com/1/statuses/user_timeline.rss?screen_name=amgarak");
curl_setopt($timeline, CURLOPT_USERPWD, $username.":".$password);
curl_setopt($timeline, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($timeline);
$result = new SimpleXMLElement($result);
echo $result->status[0]->text;
?>[/syntax]
to display my tweets.
In the tutorial I saw they work fine but I can't make it work, don't know why.

Could you please help me here
Fidbeck
Posts: 147
Joined: Tue Sep 25, 2012 11:40 pm

Re: Getting Twitter tweets

Post by Fidbeck »

added this

[syntax=php] $result = curl_exec($timeline);
print_r($result);
$result = new SimpleXMLElement($result);[/syntax]

and what I got was

Basic authentication is not supported
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: Getting Twitter tweets

Post by jacek »

Twitter made a change to their API a few years ago now that made this method no longer work. You now have to use OAuth which is a bit more complicated.
Image
Fidbeck
Posts: 147
Joined: Tue Sep 25, 2012 11:40 pm

Re: Getting Twitter tweets

Post by Fidbeck »

I can laways get the RSS file and read it through PHP :)
don't know if updates it automatically though
Post Reply