Integrating the Twitter platform

Twitter is a simple yet popular social network service that asks a simple question, "What are you doing?" Friends and followers will then have their conversation related to this topic.

We are going to demonstrate another approach of communicating with the social networking API. We will use the extension approach with the help of Java extension.

We need to set up the Twitter API by:

  1. Download the jTwitter.jar class from http://www.winterwell.com/software/jtwitter.php.
  2. Place the jTwitter.jar file in SmartFoxServer Installation Directory | Server folder.
  3. Edit the start.sh file in the Server folder to add jtwitter.jar into the classpath.

Publish latest virtual world news in Twitter

We are getting back to the emotion message that we used for updating the Facebook status. We are not trying to post the same emotion message to Twitter. Unlike the Adobe Facebook API, Twitter sets a more restrictive access from Flash player. Therefore, we are going to use the server-side extension and the Java Twitter API to access the Twitter social network service.

/* send the emotion message to Twitter, if there exists */
if (TwitterClient.isUsingTwitter) {
var params = {};
params.login = TwitterClient.twitter.login;
params.password = TwitterClient.twitter.password;
params.message = this.txtInputEmotionMessage.text;
SmartFox.sfs.sendXtMessage("virtualWorld", "updateTwitterStatus", params, "json");
}

In the server-side extension, we access the Java Twitter client by using the advanced extension technique of accessing Java class inside the ActionScript extension. We connect Twitter in server-side by providing the player's login name, password, and the message to be sent.

function hupdateTwitterStatus(cmd, param, user, fromRoom) {
var res = {};
res.cmd = cmd;
var twitter = new Packages.winterwell.jtwitter.Twitter(param. login,param.password);
twitter.setStatus(param.message);
sendResponseBack(res, user);
}

If the code works correctly, the same emotion message will be posted to both the Facebook platform and Twitter.

Publish latest virtual world news in Twitter
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.137.217.41