Hello everyone,
Recently I had a use-case to implement the Linkedin Connect with Appcelerator Titanium, but unfortunately I’m unable to find the any plug-in or module to do that. I was already using one Titanium widget called social.js which is used to connect with twitter, though Twitter and Linkedin uses OAuth for the Authentication I planned to make some modifications on the Social.js, you can find the modified social.js CommonJS module here (https://gist.github.com/4320296). Require this module and you can easily authenticate with Linkedin and Twitter as well, by that you can post the contents to Linkedin and Twitter. Use the following code after importing social.js in your code base.
this social.js module is commonjs pattern so just require it by
var social = require('social');
var linkedin = social.create({
consumerSecret : CONSUMER_SECRET,
consumerKey : CONSUMER_KEY,
site: 'linkedin'
});
linkedin.authorize();
messageContent = {
"comment" : "Testing LinkedIn for AppC",
"content" : {
"title" : "LinkedIn Appcelerator Module On SocialJS",
"submitted_url" : "http://www.appcelerator.com",
"submitted_image_url" : "https://static.appcelerator.com/images/header/appc_logo.png",
"description" : "Linkedin site support for social js"
},
"visibility" : {
"code" : "anyone"
}
};
linkedin.shareToLinkedin({
message : messageContent,
success : function() {
alert("Linkedin Posted Successfully");
},
error : function() {
alert("Error while posting");
}
});
For twitter
var twitter = social.create({
consumerSecret : TWITTER_CONSUMER_SECRET,
consumerKey : TWITTER_CONSUMER_KEY
});
twitter.authorize();
twitter.share({
message : "Message to Share",
success : function() {
alert("Tweeted Successfully");
},
error : function() {
alert("Error while tweet");
}
});
twitter.shareImage({
message : messageContent,
image : (Ti.Filesystem.getFile(Ti.Filesystem.resourcesDirectory, "KS_nav_ui.png")).read(),
success : function() {
alert("Tweeted Successfully");
},
error : function() {
alert("Error while tweet");
}
});
remember you have twitter.deauthorize(); and linkedin.deauthorize(); functions are available to deauthorize
Social.js By – Ramkumar M