Skip to content

Instantly share code, notes, and snippets.

@scripting
Last active August 29, 2015 14:03
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save scripting/9da1531966d99e355b09 to your computer and use it in GitHub Desktop.
//referenced in this blog post -- http://scripting.com/2014/07/01/twitterApiUpdatewithmedia.html
function tweetImage (status) {
var theCanvas = document.getElementById ("idCanvas");
var urlImage = theCanvas.toDataURL ();
var imgType = "image/png";
function encode (s) {
return (encodeURIComponent (s));
}
$.ajax({
type: "POST",
url: urlDefaultServer + "statuswithmedia?oauth_token=" + encode (localStorage.twOauthToken) + "&oauth_token_secret=" + encode (localStorage.twOauthTokenSecret) + "&imgtype=" + encode (imgType) + "&status=" + encode (status),
data: urlImage,
success: function (data) {
console.log ("tweetImage: " + JSON.stringify (data, undefined, 4));
},
error: function (status) {
console.log ("tweetImage: " + JSON.stringify (status, undefined, 4));
},
dataType: "json"
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment