卷曲php youtube

卷曲php youtube,php,youtube,Php,Youtube,嗨,我正在尝试在没有Zend函数的情况下构建php youtube api 这就是我到目前为止所拥有的: function upload() { $files = $_FILES; $name = $files['file']['name']; $type = $files['file']['type']; $size = $files['file']['size']; $tmp_nm = $files['file']['tmp_name']

嗨,我正在尝试在没有Zend函数的情况下构建php youtube api

这就是我到目前为止所拥有的:

function upload() {
    $files  = $_FILES;
    $name   = $files['file']['name'];
    $type   = $files['file']['type'];
    $size   = $files['file']['size'];
    $tmp_nm = $files['file']['tmp_name'];

    $data = array('name' => 'Foo', 'file' => '@'.$tmp_nm);

    print_r($_POST);
    print_r($_FILES);

    echo 'Size '.$size;

    $headers = array( 
        "Authorization: AuthSub token=".$this->auth,
        "GData-Version: 2",
        "X-GData-Key: key=".$this->dev_key,
        "Content-length: ".$size, 
        "API_XML_request"
    );

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, 'http://gdata.youtube.com/action/GetUploadToken');
    curl_setopt($ch, CURLOPT_USERAGENT, $this->user_agent);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    curl_setopt($ch, CURLOPT_TIMEOUT, 10);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

    curl_setopt($ch, CURLOPT_POST,1);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);

    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
    curl_setopt($ch, CURLOPT_REFERER,true);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION ,1);
    curl_setopt($ch, CURLOPT_HEADER,0);

    if($this->get_info)
    {
        $this->curlget_info($ch);
        }
    $output = curl_exec($ch);

    print_r($output);

    return $output;
}
我得到的错误是:

产出1 产出2 我正在使用


我花了5天时间试图解决这个问题,我询问了几个irc频道和论坛。一位朋友将我链接到这里询问,我希望有人能帮助我:)

不确定这是否是答案,但在示例页面中,他们在authsub令牌周围加了引号:

授权:AuthSub-token=“DXAA…sdb8”


也许可以试试吗?

我没有开发人员密钥,因此无法直接帮助您解决问题,但很明显,谷歌的http头有问题,因此您必须找出头中发送的内容,而不是消息正文。最好的方法是在包裹离开机器时检查电线上的包裹

所以安装,在WAMP服务器上启动它,开始捕获数据包,进行测试,然后查看数据包中的http连接。确保这是你所期望的

或者有一种方法可以让curl将数据包写入一个文件,而不是服务器,以便进行调试。我不知道

另外,这是一个很长的机会(并且会依赖于它们不符合规格),但我注意到你和你链接的其他人有“内容长度”。尝试“内容长度”以匹配示例。

相同的问题,但没有答案:S(来自其他人)
Array ( [token] => TOKEN ) Array ( [file] => Array ( [name] => 0016.png [type] => image/png [tmp_name] => D:\wamp\tmp\php178D.tmp [error] => 0 [size] => 4216 ) ) Size 4216
Google       
Error

Length Required

POST requests require a Content-length header.
Array ( [token] => TOKEN ) Array ( [file] => Array ( [name] => Film.wmv [type] => video/x-ms-wmv [tmp_name] => D:\wamp\tmp\php11D3.tmp [error] => 0 [size] => 96589 ) ) Size 96589
Google       
Error

Length Required

POST requests require a Content-length header.