Problems with upload/media using TwitterOauth



Hi All,

I switched everything over to Abraham’s TwitterOauth. WOW, great job, Abraham!

Everything works great except one for one new thing I’m trying to do. I want to post tweets with media. That media can be either a jpg or png image, or an MP4 video.

Here’s the pertinent part of the code:
$connection = new Abraham\TwitterOAuth\TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $user_token, $user_secret);
$media1 = $connection->upload(‘media/upload’, [‘media’ => ‘https://pathToImage.jpg’]);

The print_r shows " stdClass Object ( [request] => /1.1/media/upload.json [error] => media type unrecognized. "

It’s probably staring me in the face, but I just can’t see the problem.

Is there any way to push the media type? I also don’t see any media size parameter which the docs say is required.

Any help would be appreciated



media requires a local path on your filesystem. A remote URL will not work.

['media' => '/tmp/images/pathToImage.jpg']


I was worried about that. Okay, so I need to pull them in then push them out. No biggie.

Is there another function or is this more a copyright thing?


The Twitter API requires that media be uploaded to be attached to a tweet.


Ok, will do it that way. Thanks,

And, thanks again for TwitterOauth!