views:

74

answers:

2

I have a PHP script on my server that I want to run every time I post a new tweet to Twitter. Is there a way to automate this?

I could of course set up a cron job to run the script every five minutes, or run the script manually every time after tweeting, but neither of those is instant — and that’s exactly what I’m looking for.

Is it possible to use the Twitter API to run a script / get a URL every time my timeline is updated?

+1  A: 

Wouldn't it be better to just poll twitter for updates every few minutes?

Running a script every time you tweet is going to be a pain, and what if update it from a mobile device or something?

Paul Creasey
That’s exactly why I want to use the Twitter API — that way, it wouldn’t matter how I update (mobile device / Twitter client / Twitter web interface). I’m looking for a solution where Twitter would somehow execute a ‘timeline updated’ hook, and then run my PHP script (by requesting a URL).
Mathias Bynens
That won't happen. Twitter has enough to do without requesting (potentially) multiple URLS *per-tweet* and waiting for them all to respond
Gareth
@Gareth: I can see why Twitter won’t take care of it. That’s why I was hoping there was a different way, i.e. writing a web app and allowing it to access my tweets using Twitter OAuth?
Mathias Bynens
+1  A: 

No, it is not possible.

The twitter API, as well as more or less every other web site API, do not allow you to set up such a feature. They only let you request data. It is up to you to request this data regularly and do something with it.

In theory, twitter could allow you to set up a command to be run when you do make a tweet, but bear in mind that it is free.

The only way I can think of you getting this sort of set us, is to use the twitter API to send an update to twitter, and then at the same time do what ever else you want to do. This will still let you get away with just tweeting from the one place, but you will have to always use that one other place.

thecoshman
…as I feared. :( Thanks for your reply!
Mathias Bynens