Skip to content

Instantly share code, notes, and snippets.

@zachwhalen
Created June 3, 2016 12:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zachwhalen/a3adf87f5c305b90f8f92c6c2136b09c to your computer and use it in GitHub Desktop.
Save zachwhalen/a3adf87f5c305b90f8f92c6c2136b09c to your computer and use it in GitHub Desktop.
new doTweet function
function doTweet (tweet) {
var service = getTwitterService();
if (service.hasAccess()) {
var payload = {"status" : tweet }
} else {
var authorizationUrl = service.authorize();
msgPopUp('<p>Please visit the following URL and then re-run "Send a Test Tweet": <br/> <a target="_blank" href="' + authorizationUrl + '">' + authorizationUrl + '</a></p>');
}
var parameters = {
method: 'post',
payload : payload
};
try {
var result = service.fetch('https://api.twitter.com/1.1/statuses/update.json', parameters);
Logger.log(result.getContentText());
}
catch (e) {
Logger.log(e.toString());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment