Rest API usage examples for Social Media Sites (Facebook, Twitter, Linkedin, Foursquare etc.) - imona/tutorial GitHub Wiki
The social media sites which use OAuth authentication and supported by ImonaCloud platform are listed under user -> Organization Options page.
To seamlessy use the rest endpoints of these sites, first the administrator of the organization should authorize a profile to the social media site. Click on the corresponding social media site button in Organization Options and complete the authentication.
Now you are able to call rest services using the rest methods of the platform, without providing a user name and password for basic authentication. Check How to make RESTful web service calls.
Examples
To update the status (post a tweet):
var map = ["status" : ["@mentioneduser This is a test tweet! Hello world!"]];
var postUrl = 'https://api.twitter.com/1.1/statuses/update.json';
var resp = callRestServiceViaPost(postUrl, map);
To post a share to the wall (timeline):
var content = ["title" : "LinkedIn Developers Documentation On Using the Share API", "description" : "desc", "submitted-url" : "https://developer.linkedin.com/documents/share-api", "submitted-image-url" : "http://m3.licdn.com/media/p/3/000/124/1a6/089a29a.png"];
var visibility = ["code" : "anyone"];
var share = ["comment" : "Check out the LinkedIn Share API!", "content" : content, "visibility" : visibility];
callRestServiceViaPost("https://api.linkedin.com/v1/people/~/shares", share);
Foursquare
To get authorized user's details and display the first name:
var map = ["USER_ID" : "self"];
var fsqUser = callRestServiceViaGet("https://api.foursquare.com/v2/users/{USER_ID}?v=20131016", map);
info(fsqUser.response.user.firstName);
To check-in at Hagia Sophia with its venue id and display the venue name from result:
var url = "https://api.foursquare.com/v2/checkins/add?v={v}&venueId={venueId}&broadcast={broadcast}";
var urlParameters = ["v" : "20131016", "venueId" : "4bc8088f15a7ef3b6b857ada", "broadcast" : "public"];
var result = callRestServiceViaPost(url, null, urlParameters);
var placeName = result.response.checkin.venue.name;
info("Checkin yapıldı. Mekan Adı: " + placeName);