twitter发布视频使用chanked api使用php无效

时间:2017-02-16 04:40:36

标签: php api twitter

听到我的代码,当我在Twitter上传视频时,它显示我的错误

<?php
    $video = 'images/video1.mp4'; /// video size is 2 mb and it's time duration around 20 seconeds
    $code = $twitter->upload('media/upload',
                             ["command" => "INIT",
                              "total_bytes" => (int)filesize($video),
                              'media_type' => 'video/mp4']
                            );
    var_dump($code);
    $video_media_id = $code->media_id_string;
    $fp = fopen($video, 'r');
    $segment_id = 0;
    while (! feof($fp)) {
        $chunk = fread($fp, 1048576); // 1MB per chunk for this sample
        $twitter->upload('media/upload',
                         ["command" => "APPEND",
                          "media_id" => $video_media_id,
                          "media_data" => base64_encode($chunk),
                          "segment_index" => $segment_id]
                        );
        $segment_id++;
    }
    $final=$twitter->upload('media/upload',
                            ["command" => "FINALIZE",
                             "media_id" => $video_media_id]
                           );
    var_dump($final);
    $parameters = [
        'status' => 'hear is my video twittsvbn',
        'media_id' => $video_media_id
    ];
    print_r($parameters);
    $tweet=  $twitter->post('statuses/update',  $parameters);
    echo json_encode($tweet); 
    ?>
  

它向我显示错误           object(stdClass)#933(2){             [ “请求”] =&GT;             string(22)“/1.1/media/upload.json”             [ “错误”] =&GT;             string(51)“细分不会累加到提供的总文件大小。”           }

0 个答案:

没有答案