Created
June 17, 2012 04:31
-
-
Save dbaba/2943421 to your computer and use it in GitHub Desktop.
MOAT js + Chatter (Summer 2012) Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var securityToken = '<YOUR SECURITY TOKEN>'; | |
var username = '<YOUR USERNAME>'; | |
var password = '<YOUR PASSWORD>' + securityToken; | |
var consumerKey = '<YOUR CONSUMER KEY>'; | |
var consumerSecret = '<YOUR CONSUMER SECRET>'; | |
var tokenResponse = session.fetchUrlSync( | |
'https://login.salesforce.com/services/oauth2/token', { | |
method : 'POST', | |
payload : { | |
username : username, | |
password : password, | |
grant_type : 'password', | |
client_id : consumerKey, | |
client_secret : consumerSecret, | |
} | |
}, function(response) { | |
var json = response.content; | |
return { | |
accessToken : json.access_token, | |
chatterBaseUrl : json.instance_url, | |
}; | |
}); | |
var chatterResult = session.fetchUrlSync(tokenResponse.chatterBaseUrl | |
+ '/services/data/v23.0/chatter/feeds/news/me/feed-items/', { | |
method : 'POST', | |
headers : { | |
'Authorization' : 'OAuth ' + tokenResponse.accessToken, | |
}, | |
payload : { | |
text : 'こんにちは 你好 안녕하세요 Hello Hola' | |
} | |
}); | |
session.log(chatterResult); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment