Feeds + OAuth

Feeds, the successor to FeedAPI, is shaping up to be an awesome module. I am planning to use it in many, many applications, including retrieving feeds from Twitter, making video channels from YouTube, and importing credit card transactions from CSV.

A few days ago I posted about using Drupal to analyze Twitter data, and since then I've been thinking on how to implement this functionality using Feeds. Turns out some functionality is missing for a truly general solution, the first of which is retrieving private feeds. Feeds OAuth is my solution to this sub-problem.

Feeds OAuth provides a new Feeds fetcher plugin OAuthHTTPFetcher that performs OAuth authorization before requesting a feed. Here's how it works:

  • Site admin registers the Drupal site at the OAuth-enabled host, e.g. on Twitter. On this host, the callback URL should be set to http://example.com/feeds/oauth/callback/twitter. The last part of the URL will be called the site identifier, in this example twitter.
  • Site admin creates a new Feeds importer at http://example.com/admin/build/feeds/create, specifying the fetcher to be of type OAuthHTTPFetcher. In the fetcher settings, enter the standard OAuth information (consumer key, consumer secret, various URLs) as well as the site identifier entered above.
  • User can now create new Feeds nodes, specifying feed URLs that may require his OAuth authorization. If the system does not find the OAuth access token, it will prompt the user to first authenticate against the host. This will only need to happen once as the access token will be saved when authentication is complete.

That's it! You can check out a demo of Feeds OAuth in action. Now on to paging and custom field mapping :-)

Comments

Invalid protected resource url length

There doesn't seem a way to grab twitter xml's even after succesful authentication. My XML parser keeps telling me Invalid protected resource url length. Authentication worked.

Please use the Feeds OAuth

Please use the Feeds OAuth issue queue to report problems. It's easier to track them over there.

PECL OAuth

You will need to have PECL Oauth installed; which can be a bit of a problem on shared hosts

http://pecl.php.net/package/oauth