i new posting images in twitter account using php sdk.
i have tried not got solution yet.
my code
$connection = new twitteroauth($twitter_key, $twitter_secret, $token, $secret); $filecontent = file_get_contents($imageurl); $base64 = base64_encode($filecontent); $filecontent = ('data:' . $mime . ';base64,' . $base64); $connection->post("https://upload.twitter.com/1.1/media/upload.json", array("media_data" =>$filecontent)); can please ?
you're not following twitteroauth documentation uploading media.
$connection = new twitteroauth(consumer_key, consumer_secret, $access_token, $access_token_secret); $media1 = $connection->upload('media/upload', ['media' => '/path/to/file/kitten1.jpg']); $media2 = $connection->upload('media/upload', ['media' => '/path/to/file/kitten2.jpg']); $parameters = [ 'status' => 'meow meow meow', 'media_ids' => implode(',', array($media1->media_id_string, $media2->media_id_string)), ]; $result = $connection->post('statuses/update', $parameters);
Comments
Post a Comment