COMPANY
COMMUNITY
BLOG
HELP
MY ACCOUNT
EN PT ES

GeneXus Blog

Let’s keep playing... Now it's Twitter's turn!

Alejandro Cimas discusses the use of Twitter in objects and the possibility to tweet from our web panel, in addition to viewing user information in it.

 ::  By Alejandro Cimas ::


Some time ago, I uploaded to the GeneXus Server a KB that used one library of the many libraries that exist to interact with the Twitter API, more specifically Yedda Twitter C# Library. The idea was to play a bit with Twitter from GeneXus.
To use this library I use an External Object that encapsulates the whole functionality of the dll. At the time, I only tried to get my list of followers and show it in a web panel, something as simple as this:
&userString = &twitter.GetFollowersAsJSON(&user,&password)
&twitter was my external object and &userString was the json with the complete list of followers; then I uploaded the info to be able to use it through an SDT, by writing:
&Users.FromJson(&userString), where &Users was an sdt with all the info I need in connection with the followers.

But this time I wanted to be able to tweet. When I tried to use this method, UpdateAsJSON, I realized that an error occurred (in the library) upon execution that didn't allow me to use it, maybe because the dll wasn't up to date.
As opposed to when I was playing with Facebook, now I didn't want to use a javascript library and develop a UC to solve the integration, and I didn't need an interface because I only wanted to tweet, something as simple as sending my username and password and updating my status on Twitter.
That's why I decided to use another library, now Java, JTwitter. Just like most libraries, this one had many more features than I wanted, and an error occurred when importing it directly in GeneXus, so I chose to do a wrapper, make available only the features I needed and create an external object based on that wrapper:
getStatus(): Returns the user's status
setStatus(text): Tweets the 'text' text
getStatusesCount(): Returns the number of tweets for the user
getProfileImageUrl(): Returns the URL of the user's profile photo
With these four methods I have everything I need to tweet and show the user's info in my web panel:


You can download the Twitter KB from GeneXus Server, and keep playing.

Once you set up the environment, you have to copy jtwitter.jar and twitter.jar (both files are in the KB) to the lib directory of your webapp; both of them have to be in your classpath. In the KB Files you will also find the NetBeans project that I used to create the wrapper, twitter.zip, in case you want to make other things.
 
*This post was originally published on the blog From Punta Espinillo to Tokio

 
Related
GeneXus News 2.0
Channels 2.0
Tweet: A user control to place twitter in your objects
Playing with Facebook
#XXGX Twitter
Special Edition #GeneXusTheBestOf2014 :: Cloud Computing, the Internet of Things, GeneXus X Evolution 3, Success Stories, Smart Devices and ... Much More!
Release of U2 of GeneXus Evolution 3
Chopo Mobile introduces successful app in Mexico, developed with GeneXus and used for medical studies
GeneXus™ ERP Explorer and Connector for SAP® ERP Now Live on SAP Store
We have a new Download Center! The GeneXus download center has an enhanced appearance at its new location
Demand for Apple TV apps expected to double in 2016
What we've learned about GeneXus by working with Gartner (by Gabriel Simonet)
Agile or Waterfall development? (by Breogán Gonda)
We are pleased to share an interesting white paper about GeneXus, written by Kapil Ambwani from India!
Mickey, Toy Story & GeneXus: Why robots will transform developers?