I’m using themattharris Utilities and OAuth libraries for authorization, and then in my callback file after getting token I’m doing the following:
//upload media using encoded image
$image_data = file_get_contents($img_url);
$encoded_image = base64_encode($image_data);
$upload_code = $tmhOAuth->request('POST', 'https://upload.twitter.com/1.1/media/upload.json',
array(
'media_data' => $encoded_image,
),
true, // use auth
true // multipart
);
//decode the response to get the media_id for that media
$json = json_decode($tmhOAuth->response['response'], true);
$media_id = $json['media_id_string'];
//update status with media_id and provided text
$status_code = $tmhOAuth->request('POST', 'https://api.twitter.com/1.1/statuses/update.json',
array(
'media_ids' => $media_id,
'status' => "$txt"
),
true, // use auth
false // multipart
);
All functionality works as expected, except for the image being extremely small.
Here are two screenshots for reference: http://adobe.ly/2fD2DUd http://adobe.ly/2gmd7Jp