Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Calling Twitter API v1.1 From PhoneGap (Preview)

DZone's Guide to

Calling Twitter API v1.1 From PhoneGap (Preview)

· Java Zone
Free Resource

Download Microservices for Java Developers: A hands-on introduction to frameworks and containers. Brought to you in partnership with Red Hat.

I am currently working my next post which is calling the Twitter API v1.1 from PhoneGap/Cordova. I just got the code executing, but I still need to do some clean up. This post is only a preview. 

In addition to PhoneGap, I also use the following open source packages: jQuery, Backbone/Underscore, ChocolateChip-UI, and Moment.JS. The end results looks pretty good and performs pretty snappy. 

jQuery does all of the ajax calls. Unlike when used in web site code, PhoneGap apps don't have any cross domain problems. Just remember to add any web site you'd wish to call to your apps white list. 

Backbone is used for its ability to keep all of my collections neatly together. Underscore while a hard requirement for backbone is also used for its ability to render client-side templates, something that is important since Twitter is only going to feed you raw data.
ChocolateChip-UI is a fantastic package which gives your apps the correct look and feel for the platform they are running on. Using PhoneGap's merges directory, you can make a build with the correct CSS files for the desired device. Besides the shown iOS and Android, it also supports Windows Phone 8. I plan to play with that just as soon as I can get my hands on a device.

Finally there is Moment.js. It is the quintessential time handling library. Ever try to write a method to display time the way Facebook or Twitter does? You know, how long ago something was instead of when something happened? Moment has that and lots more built in. Getting the time to display correctly is a single method call.

It will probably be the weekend until I have enough time to finish the post. Besides cleaning the code up, I also want to create a plugin for it.

I am putting all of my PhoneGap code together into a book on PhoneGap. This book covers version 3+ of PhoneGap and all of things one needs to do to create production quality apps with it. Most of the code in the book has never been published. Beside using Twitter API v1.1, I cover: Audio, Video, Camera, Maps, Location, Icons, Splash pages, Debugging and setting up your build environment. I plan to self-publish on Amazon, April 2014.

Also, if you'd like more PhoneGap posts, please click the +1. I try to write post based on what I think readers like. The +1 eliminates the doubt. Thanks.

Download Building Reactive Microservices in Java: Asynchronous and Event-Based Application Design. Brought to you in partnership with Red Hat

Topics:

Published at DZone with permission of Troy Miles, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}