Weird API behavior

3 views
Skip to first unread message

Federico Fasce

unread,
Aug 14, 2008, 6:10:04 AM8/14/08
to Twitter Development Talk
Hi!
I'm using twitter API to fetch my twit page RSS and show five Twitter
update on my weblog (http://kurai.eu).
It always worked correctly (I'm using simplepie to fetch the rss and
just a foreach loop to display the tweets), but now I've noticed that
it fetches just the most recent elements (the one that appear in the
first page of my public timeline, it seems). This is a strange
behavior: the RSS shows all my tweets as normal (http://twitter.com/
statuses/user_timeline/55573.rss), I just can't fetch'em.

Please note that I never changed my code, which has always been
working right. So the problem bust be somewhere in the RSS.

Any help is appreciated.

Federico Fasce

unread,
Aug 18, 2008, 9:30:24 AM8/18/08
to Twitter Development Talk
No one can help me on this topic?

Alex Payne

unread,
Aug 18, 2008, 1:15:16 PM8/18/08
to twitter-deve...@googlegroups.com
It's possible that you're running into our caching. How often are you polling?

--
Alex Payne - API Lead, Twitter, Inc.
http://twitter.com/al3x

Matt Sanford

unread,
Aug 18, 2008, 12:44:30 PM8/18/08
to Twitter Development Talk
Hello Federico,

Can you provide a little more information? I see the error
"Invalid argument supplied for foreach()" on your page from "views/
twitter.php" line 7. Would it be possible for you to provide the
twitter.php file (assuming it's a reasonable size), or at least the
lines around that error. Also, can you confirm what RSS URL you're
using? I assume it is the URL provided on the page (http://twitter.com/
statuses/user_timeline/55573.rss) but just want to be sure. That feed
is valid per feedvalidator.org (with 1 warning) so I am assuming it's
something between the actual content and the PHP code.

— Matt

Federico Fasce

unread,
Aug 19, 2008, 7:16:40 AM8/19/08
to Twitter Development Talk
Ok, I'm gonna try. Since I'm using codeigniter as a framework some
things are a bit awkward to explain.

I have one controller which passes all the data to a view. The view
process and display the data (is a pretty basic MVC structure, without
the model)

The controller stores the RSS address in an array:

$data ['rsstwitter'] = "http://twitter.com/statuses/user_timeline/
55573.rss";

And then calls an helper function, passing the address and the number
of items I want to fetch:

$rss ['twitter'] = infoblock($data ['rsstwitter'], 5);

The helper function then uses simplepie to fetch the rss that I want:

function infoblock($url, $count)
{

$CI =& get_instance();
$CI->simplepie->set_feed_url($url);
$CI->simplepie->init();
$CI->simplepie->handle_content_type();
$CI->simplepie->strip_htmltags('img');

foreach ($CI->simplepie->get_items(0,$count) as $item):
$arr[] = array(
'bloglink' =>$CI->simplepie->get_permalink(),
'itemtitle' => $item->get_title(),
'itemdate' => $item->get_date('YmdHis'),
'itemplink' => $item->get_permalink(),
);
endforeach;

return $arr;
}

And store it in an array which will be passed to the view and
processed, like this:

<div id="twitter">
<h2 class="content">Twitter <a href="<?=$twitter[0]['bloglink'];?>"
title="Go to Twitter">&raquo;</a></h2>
<ul>
<?php
$i=1;

foreach ($twitter as $val) :
?>
<li class="link<?=$i?>"><a href="<?=$val['itemplink'];?>" title="<?=
$val['itemtitle'];?>"><?=character_limiter(substr($val['itemtitle'],
7), 40);?></a></li>
<?
$i++;
endforeach;

?>
</ul>
<a href="<?=$rsstwitter?>" title="RSS Feed for Twitter" ><img src="<?
=base_url();?>/images/feed.gif" alt="RSS Feed for Twitter"
class="feed" /></a>
</div>

The tag you see are a codeigniter feature.
The character limiter and the substring are used to cut off the
username (kurai) and to limit the number of character shown.

I hope it's clearer now...
Thank you for any advice.

Ed Finkler

unread,
Aug 19, 2008, 9:51:15 AM8/19/08
to twitter-deve...@googlegroups.com
The SimplePie devs have posted about some issues they were having with
the Twitter RSS feeds. Have you looked into those?

http://simplepie.org/blog/2008/08/16/twitter-bug/

--
Ed Finkler
http://funkatron.com
AIM: funka7ron
ICQ: 3922133
Skype: funka7ron

Federico Fasce

unread,
Aug 22, 2008, 2:52:12 AM8/22/08
to Twitter Development Talk
I see, but the problem seems to lie on the Twitter side, not on
Simplepie side (which I think is true: simplepie didn't change: I'm
still using the same version, and some months ago twitter was working
without any problem).
So, is a fix expected on this issue?

On 19 Ago, 15:51, "Ed Finkler" <funkat...@gmail.com> wrote:
> The SimplePie devs have posted about some issues they were having with
> the Twitter RSS feeds. Have you looked into those?
>
> http://simplepie.org/blog/2008/08/16/twitter-bug/
>
> --
> Ed Finklerhttp://funkatron.com
> AIM: funka7ron
> ICQ: 3922133
> Skype: funka7ron
>
Reply all
Reply to author
Forward
0 new messages