Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

How to retrieve image from direct messages and upload it as tweet directly? #261

Open
twnku opened this issue May 6, 2020 · 0 comments
Open

Comments

@twnku
Copy link

twnku commented May 6, 2020

ive retrieve a image url from direct messages using this

$parameter_get_dm = ['count' => 10];
$get_dm = $twitter->directMessages_events_list($parameter_get_dm);
foreach($get_dm->events as $item){
$file = $item->message_create->message_data->attachment->media->media_url;
}

it will show https://ton.twitter.com/i/ton/data/dm/123/123/filename.jpg after

then i use this to upload the media

$upldimg = $twitter->media_upload([
 'media' => 'https://ton.twitter.com/1.1/ton/data/dm/123/123/filename.jpg'
 ]);
 print_r($upldimg);

but it is not working
and the error log shows

[06-May-2020 14:10:39 UTC] PHP Fatal error:  Uncaught Codebird\CodebirdMediaException: Downloading a remote media file failed. in .../vendor/codebird/src/codebird.php:1924
Stack trace:
#0 .../vendor/codebird/src/codebird.php(1886): Codebird\Codebird->_fetchRemoteFile('https://ton.twi...')
#1 .../vendor/codebird/src/codebird.php(1826): Codebird\Codebird->_buildBinaryBody('https://ton.twi...')
#2 .../vendor/codebird/src/codebird.php(1800): Codebird\Codebird->_checkForFiles('media/upload', 'media', 'https://ton.twi...')
#3 .../vendor/codebird/src/codebird.php(1858): Codebird\Codebird->_getMultipartRequestFromParams('media/upload', '---------------...', Array)
#4 .../vendor/codebird/src/codebird.php(2263): Codebird\Codebird->_buildMultipart('media/upload', Array)
#5 /h in .../vendor/codebird/src/codebird.php on line 1924

how to solve this? iam still confused using this library

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant