semifor / net-twitter-lite

A lighter weight (non-Moose) Perl interface to the Twitter API
Other
26 stars 11 forks source link

API def update to 1.1 #6

Closed f055 closed 11 years ago

f055 commented 11 years ago

I updated the $api_def variable to exactly reflect the current Twitter API 1.1 REST methods (ordered like in the docs, too) and made other tweaks so the library can use 1.1 only. I didn't test all the endpoints, but most of them (on production at Twittie.com).

I simplified importing of the docs into Perl by creating a Scrapy (python crawling framework) spider that scrapes Twitter API docs and puts the data into structure used by $api_def.

I'm submitting this pull request because I think you should find this useful (and the deadline is approaching).

semifor commented 11 years ago

Thanks for this! The deadline is indeed fast approaching. I'm embarrassed by the long delay getting a release out. ATM, I'm working furiously on Net::Twitter. Traditionally, Net::Twitter::Lite has been built from Net::Twitter.

Your Scrapy scraper code may be useful for both. I need to evaluate whether to continue building Net::Twitter::Lite form Net::Twitter, or use your scraper.

For a general release, I'll actually want Twitter v1 API support by default, and an argument to new to enable v1.1 support. That way, existing code will run with the new version and users can control their migration to v1.1. This may be particularly important for users of StatusNet sites like http://identi.ca who will need Twitter API v1 support even after Twitter's deadline.

Thanks again!

f055 commented 11 years ago

You're welcome and thank you for Net::Twitter! The scraper is not perfect yet, it generates code usable for api_def, but not the complete structure - for that, there would have to be a mapping 'twitter method' -> 'net::twitter method' plus a mapping for appropriate aliases for each net::twitter method. But it's super useful to quickly extract the API into params, required and bools. It can of course be improved.

Good point about status.net and keeping API v1. I removed the v1 altogether so this kind of makes pulling directly from my code impossible. But I hope all this will help you save some time nonetheless.

semifor commented 11 years ago

Thanks again for the pull request!

I stole your $api_def, modified it slightly, and it became Net::Twitter::Lite::API::V1_1.pm.

Net::Twitter::Lite now includes Twitter API v1.1 support. Just use Net::Twitter::Lite::WithAPIv1_1 where you previously used Net::Twitter::Lite. Using Net::Twitter::Lite preserves backwards compatibility for those who need it.

Going forward, I intend to implement some scraper code like you provided in this pull request to generate the API definitions. For expediency, I just copied it this release.