Mobile Zone is brought to you in partnership with:

Troy Miles is a Southern California based software developer. He began by writing games for the Apple II, C64 and IBM PC in assembly language over 30 years ago. After burning out on games he switch to creating windows application software in C and C++. And now he develops applications for both web, mobile web and mobile devices in C#, Objective C, Java, and JavaScript. He is also a big fan of jQuery, jQuery Mobile and PhoneGap. Troy is a DZone MVB and is not an employee of DZone and has posted 23 posts at DZone. You can read more from them at their website. View Full User Profile

Calling Twitter API v1.1 From PhoneGap (Preview)

02.07.2014
| 4547 views |
  • submit to reddit

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.

Published at DZone with permission of Troy Miles, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)