I'd like to create a webpage that does the following:
1. Connects to a mysql db.
The db will have the following fields: twitterid, uniquecode, referrals
2. Connects to the twitter API
3. Has a form on the page for a user to enter their twitter handle, a submit button and a textfield for output.
The form is pre-populated with the @ sign
When they fill in their twitter name and hit submit:
It checks the db to see if the handle already exists. If so, it displays in the textfield a count of rows from 'referrals' from the db associated with that 'twitterid'.
If the handle doesn't exist - it checks the twitter API to make sure that username really exists, otherwise displays 'invalid twitter handle'.
4. If it's a new twitter name, it stores that in 'twitterid' and generates a unique 5 letter code, stored in 'uniquecode'.
5. It displays the unique code in the textfield. It should process the form and show the output without leaving the page.
6. A separate script (a cron-job perhaps?) that polls Twitter, in accordance with their policies. The poll looks for tweets that contain a certain twitter handle and a keyword, and if it finds both of those, looks for a unique code in that tweet, and checks it against the db to see if it exists.
The twitter handle and keyword it looks for should be adjustable by php variables within the code, i.e. $masterhandle $keyword
7. On finding a unique code succesfully:
It checks to see if the user who has posted, follows $masterhandle.
If the user does follow $masterhandle - it stores the twitter handle of the person posting, in the 'referrals' field in the db, associated with the 'uniquecode'.
If the user does not follow $masterhandle, then it should not store anything.