我在我的php代码中使用了youtube api版本2。如何快速将代码迁移到版本3? 我应该获得新的开发者密钥吗?我之前使用了谷歌开发者密钥:http://code.google.com/apis/youtube/dashboard/但现在我无法打开此页面,我看到502.这是一个错误。
我的youtube API 2代码:
require_once("Zend/Gdata/ClientLogin.php");
require_once("Zend/Gdata/HttpClient.php");
require_once("Zend/Gdata/YouTube.php");
require_once("Zend/Gdata/App/HttpException.php");
require_once('Zend/Uri/Http.php');
$authenticationURL = 'https://www.google.com/youtube/accounts/ClientLogin';
$httpClient = Zend_Gdata_ClientLogin::getHttpClient(
$username = $CFG->videoboard_youtube_email,
$password = $CFG->videoboard_youtube_password,
$service = 'youtube',
$client = null,
$source = 'VideoBoard',
$loginToken = null,
$loginCaptcha = null,
$authenticationURL);
$yt = new Zend_Gdata_YouTube($httpClient, 'VideoBoard', NULL, $CFG->videoboard_youtube_apikey);
$myVideoEntry = new Zend_Gdata_YouTube_VideoEntry();
$accessControlElement = new Zend_Gdata_App_Extension_Element(
'yt:accessControl', 'yt', 'http://gdata.youtube.com/schemas/2007', ''
);
$accessControlElement->extensionAttributes = array(
array(
'namespaceUri' => '',
'name' => 'action',
'value' => 'list'
),
array(
'namespaceUri' => '',
'name' => 'permission',
'value' => 'denied'
));
$myVideoEntry->extensionElements = array($accessControlElement);
$filesource = $yt->newMediaFileSource($from->fullpatch);
$filesource->setContentType($data->type);
$filesource->setSlug('slug');
$myVideoEntry->setMediaSource($filesource);
$myVideoEntry->setVideoTitle($from->author);
$myVideoEntry->setVideoDescription($from->author);
$myVideoEntry->setVideoCategory('Education');
$myVideoEntry->SetVideoTags('videoboard');
$uploadUrl = 'http://uploads.gdata.youtube.com/feeds/api/users/default/uploads';
try {
$newEntry = $yt->insertEntry($myVideoEntry, $uploadUrl, 'Zend_Gdata_YouTube_VideoEntry');
} catch (Zend_Gdata_App_HttpException $httpException) {
echo $httpException->getRawResponseBody();
$DB->delete_records('videoboard_process', array('id' => $data->id));
} catch (Zend_Gdata_App_Exception $e) {
echo $e->getMessage();
$DB->delete_records('videoboard_process', array('id' => $data->id));
}
$itemidyoutube = $newEntry->getVideoId();
if (!empty($itemidyoutube)){
$DB->set_field($table, "itemyoutube", $itemidyoutube, array("id" => $item->id));
}
答案 0 :(得分:0)
您可以参考此Migration Guide。通常,502错误可能是由Windows系统文件损坏引起的。损坏的系统文件条目可能对您的计算机的健康构成真正的威胁。之前还报告了issue,注册时存在暂时性问题
服务器,建议在http://code.google.com/apis/youtube/dashboard/gwt/index.html
访问它。这里有一个blog可能的解决方案。
您还可以查看这些相关的SO主题: