youtube上传的卷曲响应

时间:2012-06-08 09:23:34

标签: php curl

我还有一个关于YouTube上传的问题。基于我从khael这里收到的答案(replace form input file with direct file upload),脚本完美地上传了视频。但是,卷曲响应是“暂时移动”。我需要的是获取YouTube视频ID。

另一个问题是“nexturl”永远不会被调用。如果它被调用,我可以使用“$ _GET ['id']”轻松读取视频ID,并将其写入数据库。

这里是我正在使用的代码

$ch = curl_init($response->url."?nexturl=".urlencode($nexturl));
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER["HTTP_USER_AGENT"]);
curl_setopt($ch, CURLOPT_POST, true);
$post = array(
   "file"=>"@/path/to/file.avi",
   "token"=>$response->token
);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post); 
$response = curl_exec($ch);

谢谢, 弗洛里安

1 个答案:

答案 0 :(得分:1)

如果没有测试,我猜想如果你添加了FOLLOWLOCATION选项,你会得到你想要的东西:

curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
相关问题