gpt4 book ai didi

php - curl php youtube

转载 作者:行者123 更新时间:2023-12-03 05:24:03 25 4
gpt4 key购买 nike

您好我正在尝试构建没有 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
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.

输出 2
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.

我正在使用 this guide .

我试图解决这个问题 5 天,我问了几个 irc channel 和论坛。有 friend 在这里联系我问,我希望有人能帮助我:))

最佳答案

我没有开发人员 key ,因此无法直接帮助您,但显然 Google 的 http header 存在问题,因此您必须找出您在 header 中发送的内容,而不是邮件正文。最好的方法是在数据包离开机器时检查电线上的数据包。

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

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

这也是一个长镜头(并且会依赖于它们不符合规范),但我注意到您和您链接到的其他人具有“内容长度”。尝试“Content-Length”以匹配示例。

关于php - curl php youtube,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1441668/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com