0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Instagram投稿をiftttでtwitterに連携(Filterで140文字制限を考慮)

Last updated at Posted at 2023-08-14

Instagramに投稿した際に、iftttで画像と投稿をtwitterに自動投稿したかったのだけど、Instagramのハッシュタグの文字数が、twitter投稿時に邪魔になったので、filterでの処理を実施。

備忘録として残す。
IFTTT自体の条件は下記

if
any new photo by you
then
Post a tweet iwth image

下記がコード。
ハッシュタグが邪魔なので、ハッシュタグが来るか、280byte制限がきそうだったらInstagramの本文を短縮する。
InstagramのURLを連携しておきたいので、(280byte - url23byte )/ 2 = 128文字で設定してみた。

filter code
let sharpindex = Instagram.anyNewPhotoByYou.Caption.indexOf("#");

Twitter.postNewTweetWithImage.setTweet(Instagram.anyNewPhotoByYou.Caption.substring(0,Math.min(sharpindex,128))+Instagram.anyNewPhotoByYou.Url);

Twitter.postNewTweetWithImage.setPhotoUrl(Instagram.anyNewPhotoByYou.SourceUrl);
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?