rss2twi.php – Post your RSS feeds to Twitter with OAuth

In about 7 weeks, the OAuthocalypse is coming. Twitter will turn off Basic Authentication for accessing their API and you have to use OAuth. I assume, there are a lot of php scripts out there, which still use the Basic Authentication approach and not OAuth. The Basic Authentication way also breaks the password anti-pattern and is therefore very bad practice. You have been warned now :)

Here I present my little rss2twi.php script, which posts new entries from an RSS feed to Twitter with OAuth. It is certainly far from perfect, but may be a starting point for some. It is also part of my Real Time Web With A Real World Example Setup.

It has the following features:

  • It uses OAuth for authentication. You need the pecl/oauth extension for that. Maybe someone could port it to use PHP Userland OAuth

  • It can handle more than one RSS feed

  • Configuration is via a YAML file (uses sfYaml)
  • It can push updates to Prowl
  • It has a customizable URL Shortener (defaults to
  • Also has a very basic Pubsubhubbub Subscriber for immediate updates.

  • It is Open Source (Apache Software Licensed) and available at Github

I won’t go into details how it’s all done. The main class is only 245 lines of code, sample URL shorteners are also included in the code.

To use it, you first have to get the oAuth Tokens. For that you call the getOAuthToken.php file from a command line and do what it tells you to do (basically to approve the App with Twitter). You add those lines to conf/feeds.yml and then just call “rss2twitter.php” to send your RSS items to Twitter. There are more options for feeds.yml, they are described in feeds.yml-dist. You can also define the defaults in conf/defaults.yml and add more than one feed.

If you want to act as a Pubsubhubbub Subscriber you need to adjust and use “subscribe.php” and “callback.php”.

The whole script certainly could be extended and some things polished, but it works for me since quite some time and pushes all updates of this blog, Planet PHP and my private blog quite flawlessly to Twitter (and if all goes well even in real time). Feel free to use it, fork it, extend it and do whatever you want. And I hope, it helps spreading OAuth instead of the bad “asking for passwords” pattern a little bit more.

Tags: , , ,

Hands on Twitter Applications with two real life examples

At today’s Internet Briefing Developer Summit I gave a presentation about writing “Twitter applications and more”. It has some slides about and some about my real time web talk from earlier. It doesn’t have much code, it’s more from a conceptual point of view.

As always available at or the PDF link above.

This also reminded me, that I wanted to blog about my little lx_notifier class, which pushes to different services in parallel. Will do, will do :)

Tags: , , ,

The Real Time Web explained with a Real World Example

Last week I gave 2 techtalks (one in Fribourg and one in Zurich) about how we use some of the “Real Time Web” technologies in Flux CMS and its related services. The graph for this looks like that:


And the details to this can be seen in the slides.

I also plan to write some blogposts about some of the technologies used as the blue ones in the graph are written by us and Open Source (see the links at the end of the slides). And I really hope it will end up in more than just a plan :)

If you want to know something in particular before I write those posts, just ask in the comments.

Tags: , ,

A Twitter Adapter for Zend_Auth

From time to time I write some little scripts for my own needs or just to test out new stuff. And I realised, that I blog about it way too little. So here I start with my latest addition: Zend_Auth_Adapter_Twitter

The occasional webapp needs a login for managing users. Doing that by yourself is 1) cumbersome and moreover 2) very outdated (who likes to remember login/password for each and every site). As I was playing with oauth for Twitter anyway lately, I came up with a Zend_Auth Adapter for Twitter. The integration was pretty easy, but the code is very basic and rough. Nevertheless, it does the job and alongside the Openid Adapter I can offer a federated login for many people already. Now, someone should do a Zend_Auth_Adapter_Google :)

The code and a super simple example can be found in our SVN repository, it also needs the Zend_Auth_Result_Twitter class. And here’s the “Live Demo”

Tags: , ,