【问题标题】:Youtube Zend Api Function Interrupts ScriptYoutube Zend Api 函数中断脚本
【发布时间】:2012-05-09 20:07:24
【问题描述】:

这是代码:

...
require_once 'Zend/Loader.php'; // the Zend dir must be in your include_path
Zend_Loader::loadClass('Zend_Gdata_YouTube');
Zend_Loader::loadClass('Zend_Uri_Http');
$yt = new Zend_Gdata_YouTube();
$videoEntry = $yt->getVideoEntry($id_video);
....

在这个脚本的几行中,有时(我不明白为什么这种情况只会发生几次,而不是在其他情况下,似乎是随机的) Zend_Gdata_YouTube() 或 getVideoEntry($id_video) 没有返回,脚本死了.在脚本的文件夹中没有日志文件,所以我不明白它在运行时会发生什么。任何帮助或建议将不胜感激,谢谢。

【问题讨论】:

    标签: php api zend-framework youtube


    【解决方案1】:

    我遇到了同样的问题,但上传 youtube 视频。通过在 Zend 文件中四处挖掘,我找到了脚本死去的地方。在Zend/Gdata/HttpAdapterStreamingSocket.php:

    while ($chunk !== FALSE) {
        if (! @fwrite($this->socket, $chunk)) {
            require_once 'Zend/Http/Client/Adapter/Exception.php';
            throw new Zend_Http_Client_Adapter_Exception(
                'Error writing request to server');
        }
        $chunk = $body->read(self::CHUNK_SIZE);
    }
    

    通过从fwrite 中删除@,我得到了超出最大执行时间的错误。通过禁用循环的执行时间限制,错误不再出现:

    $executionTime = ini_get('max_execution_time');
    set_time_limit(0);
    while ($chunk !== FALSE) {
        if (! fwrite($this->socket, $chunk)) {
            require_once 'Zend/Http/Client/Adapter/Exception.php';
            throw new Zend_Http_Client_Adapter_Exception(
                'Error writing request to server');
        }
        $chunk = $body->read(self::CHUNK_SIZE);
    }
    set_time_limit($executionTime);
    

    这可能不是您的确切问题,但请尝试在 Zend 文件中查找 @fwrite 调用并执行相同的操作,因为您的脚本可能在将块写入套接字时以及在抑制错误的函数上死亡。

    【讨论】:

    • 这并没有解决问题,和上传非常大的文件有关,我上传3GB+才看到这个错误,无论如何要解决?
    猜你喜欢
    • 1970-01-01
    • 2010-10-15
    • 2011-06-14
    • 2010-12-15
    • 1970-01-01
    • 2013-10-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多