Given an image at a certain address, http://www.thissite.will/never/be-finished.png
, what's the easiest way to share it to Twitter, preferably without a card?
Users customize an SVG, and when they're satisfied, I convert it to a PNG and store it on my server.
I want to give them the option of sharing the image on Twitter. They click on a button (which I can implement), and a dialog box opens, where they can add to the tweet (which should already contain the picture).
I know similar questions have been asked on this site before, but I do not want to use a "card" to share the image. Instead, I want a typical, non-card Tweet, just with an image (like this).
I've looked through the Twitter Developer Documentation repeatedly, but I can't find helpful information. The POST statuses/update_with_media method is deprecated, and the link to the "Uploading Media Guide," a suggested replacement, is broken. This guide, I assume, is what it intended to link to, but it has no JavaScript code to suggest how this should actually be implemented.
Please help.
My attempt, based off of POST media/upload
:
$.ajax({
url: "https://upload.twitter.com/1.1/media/upload.json",
format: "post",
data: {"data" : link}
}).success(function(response) {
console.log(":)");
console.log(response);
}).fail(function(response) {
console.log(":(");
console.log(response.responseText);
});
This fails. The responseText
is {"errors":[{"code":215,"message":"Bad Authentication data."}]}
.
Basically, I want to do something similar to what StackOverflow does. When you click "share" on a question, then select Twitter, a new window pops up populated with a link to the question and where users can write their own message. (Twitter provides the interface.)
In my case, however, when the tweet is sent, rather then there being a link back to the page and some text pulled from it, I'd like to have just an image.