Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
//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