Allowing specific Twitter users to view WordPress blog

I’ve got a simple requirement, but can’t for the life of me figure out how to do it: I’d like to allow specific Twitter users to view a WordPress blog. These users are all followers of a [locked] Twitter account.

I presume I’d need to use oAuth but all plugins and tutorials I’ve found are generic – ie you login with Twitter, and that’s it. I’d like to go an additional step and check that the user is following the locked account too.

Read More

Doable?

Related posts

Leave a Reply

1 comment

    1. Create a Twitter app associated with your protected account. (I would give you the link, but I don’t have enough SO points to have more then 2 links in a post. So just Google this step)

    2. Create a custom WordPress page template for your protected pages. See http://codex.wordpress.org/Pages#Creating_Your_Own_Page_Templates

    The following steps should be placed inside your page template code:

    1. Once the user is logged in using your Twitter OAuth plugin that you mention, find the current user’s Twitter ID, it will almost certainly be kept in the $_SESSION global somewhere.

    2. Use a PHP wrapper to the Twitter API (like this one https://github.com/abraham/twitteroauth/blob/master/DOCUMENTATION) to call the Twitter API’s GET /friends/ids method with the screen_name set to your Twitter handle. You will need the CONSUMER KEY and SECRET given to you in step 1. This will give you a list of your followers.

    3. Check if the logged in user’s id is in the list of user ids returned by the previous step. If so then call the_content() to render the pages content, if not then don’t make that call.

    4. Sacrifice 3 grain-fed male sheep, 2 creatures of the night and 1 black, legless insect.