Hi,
I’m trying to upload an image using the below code with Oauth.
$image_path = "C:\images\img.png";
$connection_camp = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $access_token, $access_token_secret);
$media_response = $connection_camp->upload('media/upload', array('media' => file_get_contents($image_path)));
But I couldn’t get any response(not even an error) from twitter api. I’ve already tried media-data with base64 encode but couldn’t get any response. The image path is also correct.
Kindly suggest.
Thanks.
1 Like
The documented way to do image upload is:
$media2 = $connection->upload('media/upload', ['media' => '/path/to/file/kitten2.jpg']);
So drop the file_get_contents and it should work.
1 Like