Problems with upload/media using TwitterOauth

restapi
rest
media-upload

#1

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’]);
print_r($media1);

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

Paul


#2

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

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

#3

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?


#4

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


#5

Ok, will do it that way. Thanks,

And, thanks again for TwitterOauth!