0

I upload an image with API v1.1 and get a media ID.Then I try to tweet with this media ID using API v2, and I encounter errors. How can I properly use the media ID from API v1.1 in API v2?

Here's my JavaScript code(Google Apps Script).

const tweetUrl = "https://api.twitter.com/2/tweets";
const tweetPayload = {
    "text": "Test",
    "attachments": { "media_keys": [mediaId] }
};
const tweetOptions = {
    method: "POST",
    headers: { Authorization: 'Bearer ' + getService().getAccessToken() },
    payload: JSON.stringify(tweetPayload)
};
const tweetResponse = UrlFetchApp.fetch(tweetUrl, tweetOptions);
Logger.log(tweetResponse.getContentText());

Any suggestions are appreciated. Thanks!

mame
  • 11
  • 1

0 Answers0