Issue with Twitter API in getting Followers' Tweet

21 views
Skip to first unread message

Kevin_Blogs

unread,
Aug 1, 2008, 3:12:52 PM8/1/08
to Twitter Development Talk, al...@al3x.net
Hi,
I am playing with Twitter APIs since couple of days... Ofcourse i
am newbie to twitter api, however not new for APIs.. i am already
using Google feed api and few others. Ok lets come to the point. I am
trying to get the latest tweet of my followers. I am using CURL.

when i am trying to get the followers' tweet direct through "http://
twitter.com/statuses/followers.xml", sometime it gives me and
sometimes it doesn't. See the below data (only two followers info i
mentioned here) of my http://twitter.com/statuses/followers.xml :
- <users type="array">
- <user>
<id>334503</id>
<name>Jajah</name>
<screen_name>jajah</screen_name>
<location>Mountain View, CA</location>
-<description>
You provide us the international phone number of a friend,
and we give you a local
number for them - Call the world like it's local! Local
rates, no contract!
</description>
-<profile_image_url>
http://s3.amazonaws.com/twitter_production/profile_images/17595742/Jajah_normal.png
</profile_image_url>
<url>http://www.jajah.com</url>
<protected>false</protected>
<followers_count>800</followers_count>
</user>

- <user>
<id>991221</id>
<name>Bloggers Blog</name>
<screen_name>bloggersblog</screen_name>
<location>Dallas</location>
- <description>
Blogging, media and Twitter news. Editor: Greg K. - I'm
also in Plurk: http://twurl.nl
/cg85wy
</description>
-<profile_image_url>
http://s3.amazonaws.com/twitter_production/profile_images/54743504/bb_normal.gif
</profile_image_url>
<url>http://www.bloggersblog.com</url>
<protected>false</protected>
<followers_count>14135</followers_count>
-<status>
<created_at>Wed Jul 30 23:06:53 +0000 2008</created_at>
<id>873077044</id>
-<text>
@gregdelima sorry that number I gave you was only
for the 14-17 age group. The
correct totals are Women: 24,821,901 Men: 20,559,526
</text>
<source>web</source>
<truncated>false</truncated>
<in_reply_to_status_id>873049022</in_reply_to_status_id>
<in_reply_to_user_id>9929562</in_reply_to_user_id>
<favorited/>
</status>
</user>

Here, one can see that it doesn't show "Jajah" follower status (and so
his latest tweet), however it shows the "Bloggers Blog" status and
latest tweet. I don't understand why is this happening. And this is
not happening every time. Few times it shows latest tweet for "Jajah".
I dont have any clue for this biasing philosophy of twitter ;).

The i found alternate method for getting tweets. What i am doing is
first get the followers. Then i read tweet from the follower's
timeline using below small php code :

$follower_rss = "http://twitter.com/statuses/user_timeline/".
$follower_name.".rss";
$rss = $t->getrss($follower_rss);

where, getrss function simply initiate another curl request :

function getrss($url) {
$request = $url;
return $this->process($request);
}

function process($url,$postargs=false) {

$ch = curl_init($url);

if($postargs !== false) {
curl_setopt ($ch, CURLOPT_POST, true);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $postargs);
}

if ($this->username !== false && $this->password !== false)
curl_setopt($ch, CURLOPT_USERPWD, $this->username.':'.
$this->password);

curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_NOBODY, 0);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_USERAGENT, $this->user_agent);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
//curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $this->headers);

$response = curl_exec($ch);

$this->responseInfo=curl_getinfo($ch);
curl_close($ch);

if(intval($this->responseInfo['http_code'])==200) {
if(class_exists('SimpleXMLElement')) {
//$xml = new SimpleXMLElement($response);
$xml = simplexml_load_string($response);
return $xml;
} else {
return $response;
}
} else {
return false;
}
}

unfortunately this way, i am able to get latest tweet without
failure... However this method is slow (ofcourse yes)

Anyone can guide me for better way and for above issue.

Early response will be highly appreciated.

Thanks in advance.

Kevin
(http://smashingfeeds.com)

Kevin_Blogs

unread,
Aug 2, 2008, 11:58:01 PM8/2/08
to Twitter Development Talk
Any help ???




On Aug 2, 12:12 am, Kevin_Blogs <blogfisher...@gmail.com> wrote:
> Hi,
>    I am playing with Twitter APIs since couple of days... Ofcourse i
> am newbie to twitter api, however not new for APIs.. i am already
> using Google feed api and few others. Ok lets come to the point. I am
> trying to get the latest tweet of my followers. I am using CURL.
>
> when i am trying to get the followers' tweet direct through "http://
> twitter.com/statuses/followers.xml", sometime it gives me and
> sometimes it doesn't. See the below data  (only two followers info i
> mentioned here) of myhttp://twitter.com/statuses/followers.xml:
> - <users type="array">
>    - <user>
>       <id>334503</id>
>       <name>Jajah</name>
>       <screen_name>jajah</screen_name>
>       <location>Mountain View, CA</location>
>       -<description>
>             You provide us the international phone number of a friend,
> and we give you a local
>             number for them - Call the world like it's local! Local
> rates, no contract!
>       </description>
>       -<profile_image_url>
>            http://s3.amazonaws.com/twitter_production/profile_images/17595742/Ja...
>       </profile_image_url>
>       <url>http://www.jajah.com</url>
>       <protected>false</protected>
>       <followers_count>800</followers_count>
>    </user>
>
>    - <user>
>       <id>991221</id>
>       <name>Bloggers Blog</name>
>       <screen_name>bloggersblog</screen_name>
>       <location>Dallas</location>
>       - <description>
>             Blogging, media and Twitter news.  Editor: Greg K. - I'm
> also in Plurk:http://twurl.nl
>             /cg85wy
>       </description>
>       -<profile_image_url>
>            http://s3.amazonaws.com/twitter_production/profile_images/54743504/bb...
Reply all
Reply to author
Forward
0 new messages