Jun 292009

I wrote this PHP script in order to include the latest tweets from my Twitter on my website. It retrieves the RSS feed, parses it and pastes a number of tweets (along with timestamp and link) to HTML.

[[ OLD:
Before I can / want to release it under some free software license, I would appreciate it if some of you PHP nerds could review the code. I am mainly concerned about security issues rather than formatting and coding style. Since I am no pro in PHP coding, I will probably have done some things quite clumsily.

So please point out security problems as well as other major issues. (For example, if anybody knows how to stop parsing after max items were dealt which, please let me know 🙂 ).

[UPDATE 07/08/2009]
(HTTP) Links are now made clickable.

[UPDATE 15/12/2009]
The script was released under the Creative Commons Attribution 3.0 Unported License today.
Download the PHP code at http://blog.haraldkraft.de/wp-content/uploads/2009/12/parsetwitter.php_.txt and feel free to reuse and tweak my script (along with mentioning my name as suggested in the license information in the code).

Email me at blog {at} haraldkraft(.)de (or comment)

Creative Commons License
This work is licensed under a Creative Commons Attribution 3.0 Unported License.

  7 Responses to “Twitter PHP script”

  1. thanks for your contribution and I hope will be useful the last boot cd
    thanks friend

  2. The script was released today – go ahead and use it!

  3. Hey guys,

    does this scrpit also work to pull ordniary rss?

    greetz.. and could you decide which license to use?
    I’m planning on integrating your source into a project of mine…

  4. Thanks Marc for pointing this out.

    At the moment the limit is 150 calls per 60 minutes (according to their FAQ) – even though I could not confirm that number in first tests.

    If I was forced to work around this, I’d first cronjob downloading the RSS feed every minute to another location and use that URL in the script.
    Maybe in a later version the script might be able to perform this itself.

  5. Just so everyone knows, apparently Twitter limits the requests made to 60 within an hour so if you have more hits than that in an hour Twitter will block this script. There is a workaround which we used: to just contact Twitter once in 5 minutes and to save the results on our own server…

    Cheers 🙂

  6. Everyone discard my earlier comment, this script works absolutely fine, my earlier problem had to do with encoding on my part, nothing to do with Haraldkraft’s work which is awesome :)!


  7. Hmmmm, I’ve got a problem with displaying German Umlaute 🙁 – otherwise it works fine for me so far, thanks for your work!

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">