Help - Media upload with codebird PHP libary



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

    // note: consumerKey, consumerSecret, accessToken, and accessTokenSecret all come from your twitter app at
    \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?


@xrs For video uploads, you have to use the chunked media upload api. Based on (“Video files” section), it looks like you have to use codebird lib differently for video files.


This topic was automatically closed after 2 days. New replies are no longer allowed.