I have a command that pushes tweets, using the 1.1 version for the twitter API.
It has been working but recently (not entirely sure when), has stopped posting images to twitter.
With extensive debugging there doesn't seem to be any errors at all, but just no images in feed.
Could this be due to changes with the new v2 of the api ? Has this functionality been deprecated ?
public function send($message, $media = null, $options = [])
{
$mediaIds = [];
foreach ((array) $media as $item) {
$res = $this->request(
'https://upload.twitter.com/1.1/media/upload.json',
'POST',
null,
['media' => $item]
);
$mediaIds[] = $res->media_id_string;
}
return $this->request(
'statuses/update',
'POST',
$options + ['status' => $message, 'media_ids' => implode(',', $mediaIds) ?: null]
);
}
Any ideas gratefully received.
mediaIds
array(1) {
[0]=>
string(19) "xxxxxxxx"
}
response from media post
object(stdClass)#1626 (5) {
["media_id"]=>
int(xxxx)
["media_id_string"]=>
string(19) "xxxxx"
["size"]=>
int(129032)
["expires_after_secs"]=>
int(86400)
["image"]=>
object(stdClass)#1623 (3) {
["image_type"]=>
string(9) "image/png"
["w"]=>
int(400)
["h"]=>
int(400)
}
}
Successfully posted item to twitter
object(stdClass)#1625 (23) {
["created_at"]=>
string(30) "Thu Dec 02 11:55:42 +0000 2021"
["id"]=>
int(1466375520866775045)
["id_str"]=>
string(19) "1466375520866775045"
["text"]=>
string(20) "New test message 401"
["truncated"]=>
bool(false)
["entities"]=>
object(stdClass)#1624 (4) {
["hashtags"]=>
array(0) {
}
["symbols"]=>
array(0) {
}
["user_mentions"]=>
array(0) {
}
["urls"]=>
array(0) {
}
}
["source"]=>
string(67) "<a href="https://www.co-kinetic.com" rel="nofollow">Co-Kinetic </a>"
["in_reply_to_status_id"]=>
NULL
["in_reply_to_status_id_str"]=>
NULL
["in_reply_to_user_id"]=>
NULL
["in_reply_to_user_id_str"]=>
NULL
["in_reply_to_screen_name"]=>
NULL
["user"]=>
object(stdClass)#1621 (43) {
["id"]=>
int(68679793)
["id_str"]=>
string(8) "68679793"
["name"]=>
string(13) "glen lockhart"
["screen_name"]=>
string(12) "glenlockhart"
["location"]=>
string(14) "Sheffield, UK."
["description"]=>
string(68) "I like tech and burritos and probably other things. Mostly burritos."
["url"]=>
NULL
["entities"]=>
object(stdClass)#1627 (1) {
["description"]=>
object(stdClass)#1628 (1) {
["urls"]=>
array(0) {
}
}
}
["protected"]=>
bool(false)
["followers_count"]=>
int(55)
["friends_count"]=>
int(163)
["listed_count"]=>
int(2)
["created_at"]=>
string(30) "Tue Aug 25 12:29:11 +0000 2009"
["favourites_count"]=>
int(109)
["utc_offset"]=>
NULL
["time_zone"]=>
NULL
["geo_enabled"]=>
bool(false)
["verified"]=>
bool(false)
["statuses_count"]=>
int(201)
["lang"]=>
NULL
["contributors_enabled"]=>
bool(false)
["is_translator"]=>
bool(false)
["is_translation_enabled"]=>