Eamorr
Eamorr

Reputation: 10022

Getting started with Twitter API

I'm developing an app whereby users tweet me (@Eamorr) and I respond with the phone number of the nearest business based on the geolocation embedded in the tweet.

I'm not really sure where to start and thought I'd ask the community.

I'd like to make this as real-time as possible - i.e. where there is minimal delay between the user tweeting @Eamorr and them receiving the phone number. Is node.js a good solution for this?

Btw, my server runs php, but I'm language agnostic, so any suggestions are most welcome.

Upvotes: 0

Views: 422

Answers (3)

air-dex
air-dex

Reputation: 4178

The first thing you have to do is bookmarking Twitter Developers (https://dev.twitter.com/) in your web browser. It will be your Holy Bible for everything related to the Twitter API. To know what to do, you should go to the Documentation section and read the getting started pages. They are very helpful.

Upvotes: 0

Terence Eden
Terence Eden

Reputation: 14334

Do not repeatedly call the twitter server!

You want to use the Twitter Streaming API. This will give you real-time access to tweets being directed to you.

Specifically, you want to have a User Stream. This will push data to your server every time someone sends you a tweet.

Once you receive the tweet, you can then reply to it.

Upvotes: 2

Fresheyeball
Fresheyeball

Reputation: 30015

My 2 cents.

Twitter goes down somewhat frequently, and the api will always have a delay of some time, so I recommend the following:

Step One Do a server to server GET via php, passing the desired params to the twitter api. http://tareq.wedevs.com/2009/05/playing-with-twitter-json-using-php/

Step Two Use Php to parse and 'cache' json into mySQL. This way if twitter goes down, your site wont. Also your users wont have to wait for an api call to complete.

Step Three Use standard mySQL and PHP to return html to your users.

Steps one and two, should be automated to run every 5 minutes or so to keep data fresh. Imho, reliability is king, and node.js is toxic. If you already are comfortable with lamp, then use lamp.

Upvotes: 1

Related Questions