我正在尝试在YouTube视频上发布评论...为此,我使用YouTube api。下面是代码:为什么这个CURL请求不起作用?
<?php
$message="Just Some Comment...";
$developer_key="<!---visit demo for actual code---!>";
$access_token=$_GET['code'];
if(!$access_token){ Header("Location: <!---visit demo for actual code---!>");}
$video_id="I3LMKhu2-vo";
$message_xml='<?xml version="1.0" encoding="UTF-8"?>
<entry xmlns="http://www.w3.org/2005/Atom" xmlns:yt="http://gdata.youtube.com/schemas/2007">
<content>' . $message . '</content>
</entry>';
$url = "http://gdata.youtube.com/feeds/api/videos/" . $video_id . "/comments";
$header = array('Content-Type: application/atom+xml', 'Content-Length: ' . strlen($message_xml), 'Authorization: Bearer "' . $access_token . '"', 'GData-Version: 2', 'X-GData-Key: key=' . $developer_key);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_POSTFIELDS, "$message_xml");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
echo curl_error($ch);
curl_close($ch);
echo $access_token;
?>
如果我引用这是隐藏个人的东西,但你可以在votm.net78.net 看到演示所以我的问题是,为什么不评论出现在视频,即使用户已经发送授权令牌?请问我可以帮忙吗?谢谢!
'$ result'中有什么?如果在'$ result = curl_exec($ ch);'后面加上'var_dump($ result);',你会看到什么? – 2013-04-01 07:34:35