CodeIgniter Forums
twitter - tweetsigniter stopped working - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: twitter - tweetsigniter stopped working (/showthread.php?tid=33582)



twitter - tweetsigniter stopped working - El Forum - 09-01-2010

[eluser]martynrlee[/eluser]
Hi Guys,

Anyone having issues with tweetsigniter? Over the last few days seems to have stopped pulling data in.

Even a simple test such as:

Code:
$this->load->library('tweetsigniter');
        
$this->tweetsigniter->setInfo('myusername','mypassword','3');

print_r($this->tweetsigniter->twitterFollowers());

This is not pulling any twitter info through. I have not changed anything and cant work out why not working on two sites I have tweetsigniter installed on.

Any ideas?

Martyn.


twitter - tweetsigniter stopped working - El Forum - 09-01-2010

[eluser]martynrlee[/eluser]
ok realised its related to oauth. fairly new to twitter api so didnt hear about that.


twitter - tweetsigniter stopped working - El Forum - 09-01-2010

[eluser]martynrlee[/eluser]
Still a bit confused actually...

I just want to use oauth and pull in the latest 3 tweets from a company to a page - pretty simple.

I dont want a user to have to log in to twitter to get to the page.

Can anyone point me in the right direction of the simplest method to acheive this?

Thanks,

Martyn.


twitter - tweetsigniter stopped working - El Forum - 09-01-2010

[eluser]eoinmcg[/eluser]
assuming you're using php5, here's some code i put together recently:

Code:
$tweets = get_tweets('starfishweb');

foreach($tweets as $tweet)
{
    var_dump($tweet);
}


    function get_tweets($twitter_name, $count=3)
    {

        $url = "http://twitter.com/statuses/user_timeline/$twitter_name.xml";

        @$xml = simplexml_load_file($url);

        if ( !$xml )
        {
            return $this->error();
        }


        $data = array();
    
        $n = 1;
    
        foreach ( $xml->status as $status )
        {
            // convert this to a unixtimestamp
            $date = strtotime( (string) $status->created_at);

            $data['tweets'][$n]['time'] = date('d M H:i', $date);
            $data['tweets'][$n]['text'] = auto_link($status->text); // you should load the url helper to make use of autolink
            
            $n++;
        }
        
        return array_slice($data['tweets'], 0, $count);

        
    }

there's room for improvement but you get the idea.

you're obviously going to want to cache, given the timelag in fetching the data from twitter


twitter - tweetsigniter stopped working - El Forum - 09-01-2010

[eluser]martynrlee[/eluser]
Oh that makes sense, thank you very much 'eoinmcg'!

Didnt think that with it being a public xml you dont even need to have authentication.

sweet, thanks again.