:: 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.