Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/290.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Twitter:OpenSSL\u read:Connection reset by peer,errno 104_Php_Twitter - Fatal编程技术网

Php Twitter:OpenSSL\u read:Connection reset by peer,errno 104

Php Twitter:OpenSSL\u read:Connection reset by peer,errno 104,php,twitter,Php,Twitter,Twitter:OpenSSL\u read:Connection reset by peer,errno 104 Twitter:操作在5000毫秒后以0字节超时 收到 这是我在尝试将视频文件分块上传到Twitter时(随机)遇到的两个错误 1.5MB file = Most of the times uploads, sometimes gives error 10MB file = Always gives error (one of the above, randomly) 20MB f

Twitter:OpenSSL\u read:Connection reset by peer,errno 104

Twitter:操作在5000毫秒后以0字节超时 收到

这是我在尝试将视频文件分块上传到Twitter时(随机)遇到的两个错误

1.5MB file = Most of the times uploads, sometimes gives error
10MB file = Always gives error (one of the above, randomly)
20MB file = Always gives error (one of the above, randomly)
我的代码与此非常相似:我正在使用库

通过调试,我知道此函数中会抛出错误

报告说:

“媒体”正在上载的原始二进制文件内容。一定是
已解决

我所要做的就是更改我使用的库,它立即开始工作,没有任何重大更改

function append($mediaId, $fileUrl)
{
    $segmentIndex = 0;

    $handle = fopen($fileUrl, 'r');

    while (!feof($handle)) 
    {
        $chunk = fread($handle, 4 * 1024 * 1024); // 4mb 

        $params = ['command' => 'APPEND', 'media_id' => $mediaId, 'media_data' => base64_encode($chunk), 'segment_index' => $segmentIndex];
        $this->tw->uploadCustom('media/upload', $params);

        $segmentIndex++;
    }
}