Saturday, 4 September 2021

Collect url of original image from a Telegram post to publish to Instagram via API

The project is being created in Google App Script, which is based on Javascript.

I have a bot on my channel that sends me data whenever a post is edited or published:
https://core.telegram.org/bots/

var token = "AAAAAAAAAAAA";
var telegramUrl = "https://api.telegram.org/bot" + token;
var webAppUrl = "https://script.google.com/macros/s/BBBBBBBBBBBB/exec";

function setWebhook() {
  var url = telegramUrl + "/setWebhook?url=" + webAppUrl;
  var response = UrlFetchApp.fetch(url);
}

function doPost(e) {
  var contents = JSON.parse(e.postData.contents);

  //Link Photo
  var body = contents.channel_post.photo;
  Logger.log(body);
}

But the callbacks are only charging the thumbnail ID, I can't find the id to original image.


  • Aditional infos:
var contents = JSON.parse(e.postData.contents);
Logger.log(contents);

Return:

{channel_post={message_id=258.0, chat={type=channel, title=AAAAAAAAAA, id=-1.0000000000000}, sender_chat={type=channel, id=-1.0000000000000, title=AAAAAAAAAA}, caption=Hello

World., date=1.123456789, photo=[Ljava.lang.Object;@2b211b0e}, update_id=5.00000000}
Logger.log(contents.channel_post.photo); //Ljava.lang.Object

Return:

{width=90.0, file_id=XXXXXXXXXXXXXXX, height=51.0, file_size=1301.0, file_unique_id=YYYYYYYYYYYY}

The image result download is (as can be seen, it is tiny, it is a thumbnail of the real image, not the real image specifically):
enter image description here



from Collect url of original image from a Telegram post to publish to Instagram via API

No comments:

Post a Comment