Tweet to Unlock with jQuery & PHP
Everyone knows how important role Twitter can play to bring new visitors to your site, and Tweet to unlock can only amplify the whole thing by requiring visitors to Tweet about your page in order to unlock the downloadable items or premium content. In this tutorial article, let’s create simple “Tweet to Unlock” feature for your web page using jQuery Ajax and PHP.
Events are triggered when user successfully tweets the page, to capture some information from Twitter, we can add a “listeners” to the actions users perform in Web Intents. Once we know the user has Twitted the page, we can make an Ajax request to a PHP file, which will respond to this request by sending the unlocked data to user browser. Here’s complete code example of a page which has some content to be unlocked by Twitting.
PHP Ajax Response
When user Tweets the page successfully, an Ajax request is made to PHP file send_resources.php, and the server returns this HTML snippet, which contains unlocked item or anything goes wrong HTTP error is sent to browser.
This is the example usage of Twitter Web Intents, and I found there are some limitations to what you can achieve with it, but I am sure it will serve the purpose and if there’s more to it let’s dig and share, good luck!
The link to downloadable sample code is locked, Please Tweet this page to unlock it.
Tweet to Unlock Download
Saran Chamling. (He loves the web technology, and enjoys designing, exploring and writing about it @saaraan.com).