我已经知道如何在我的Twitter帐户上使用PHP发布图片。我使用twitteroauth,它可以正常使用这段代码。
$with_media = '';
$texte = ltrim(rtrim($line["texte"]));
if($line["image"] > 0) {
$image = strval($line["image"]);
$file = 'twitpic/' . $image . '.jpg'; // this is path of local file
$type = 'jpg'; // jpg
$name = $image . '.jpg'; // image.jpg
$media = '@' . realpath($file) . ';type=image/' . $type . ';filename=' . $name;
$with_media = '_with_media';
}
$status = $texte . ' - ' . $turl;
$params = array('media[]' => $media, 'status' => $status);
$code = $tmhOAuth->request( 'POST', 'https://api.twitter.com/1.1/statuses/update' . $with_media . '.json', $params, true, true); // use_auth and multipart
好吧..可能它不是最好的编码......但是它有效。
所以,现在,经过多次尝试,我试图找出自己如何同时发布最多3张图片。尝试了许多不同的事情,但从未成功过。我甚至不知道是否可能。
有人可以帮忙吗?并且可以解释如何以同样的方式发布.GIF?
非常感谢。
FZ
答案 0 :(得分:0)
您使用的是deprecated API - 不再支持update_with_media
选项。
According to the documentation,这是你必须做的。
media_id_string
回复。statuses/update
创建推文 - 参数media_ids
设置为已上传图片的ID。这将允许您将多个静止图像发布到Twitter。您一次只能发布一个GIF或视频。