I’m trying to tweet mp4 file with php using codebird library.
Script works fine with GIF’s. But If I try to upload mp4 file it allways fails with error 401.
$reply = $cb->media_upload(array(
'media' => $image
));
echo $reply->httpstatus; --------------->>>>>>>returns error 400
All code that I use is:
function tweet($message,$image) {
// add the codebird library
require_once('codebird.php');
// note: consumerKey, consumerSecret, accessToken, and accessTokenSecret all come from your twitter app at https://apps.twitter.com/
\Codebird\Codebird::setConsumerKey('xx', 'xx');
$cb = \Codebird\Codebird::getInstance();
$cb->setToken('xx', 'xx');
//build an array of images to send to twitter
$reply = $cb->media_upload(array(
'media' => $image
));
echo $reply->httpstatus;
//upload the file to your twitter account
$mediaID = $reply->media_id_string;
//build the data needed to send to twitter, including the tweet and the image id
$params = array(
'status' => $message,
'media_ids' => $mediaID
);
//post the tweet with codebird
$reply = $cb->statuses_update($params);
echo $reply->httpstatus;
}
$link= "/twitter/test.mp4";
tweet("Tweet test",$link);
Any ideas what could be wrong in this code?