Created
June 3, 2016 12:58
-
-
Save zachwhalen/a3adf87f5c305b90f8f92c6c2136b09c to your computer and use it in GitHub Desktop.
new doTweet function
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
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