此操作所需的开发人员密钥 [英] Developer key required for this operation
问题描述
我找不到此操作所需的开发人员密钥"问题的解决方案.
I dont find the solution for my "Developer key required for this operation" problem.
这是我的代码:
require_once 'Zend/Loader.php'; // the Zend dir must be in your include_path
Zend_Loader::loadClass('Zend_Gdata_YouTube');
$yt = new Zend_Gdata_YouTube();
Zend_Loader::loadClass('Zend_Gdata_AuthSub');
Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
$authenticationURL= 'https://www.google.com/accounts/ClientLogin';
$httpClient =
Zend_Gdata_ClientLogin::getHttpClient(
$username = '************@gmail.com',
$password = '************',
$service = 'youtube',
$client = null,
$source = '************', // a short string identifying your application
$loginToken = null,
$loginCaptcha = null,
$authenticationURL);
// Note that this example creates an unversioned service object.
// You do not need to specify a version number to upload content
// since the upload behavior is the same for all API versions.
$yt = new Zend_Gdata_YouTube($httpClient);
// create a new VideoEntry object
$myVideoEntry = new Zend_Gdata_YouTube_VideoEntry();
// create a new Zend_Gdata_App_MediaFileSource object
$filesource = $yt->newMediaFileSource('asd.avi');
$filesource->setContentType('video/x-ms-wmv');
// set slug header
$filesource->setSlug('asd.avi');
// add the filesource to the video entry
$myVideoEntry->setMediaSource($filesource);
$myVideoEntry->setVideoTitle('My Test Movie');
$myVideoEntry->setVideoDescription('My Test Movie');
// The category must be a valid YouTube category!
$myVideoEntry->setVideoCategory('Autos');
// Set keywords. Please note that this must be a comma-separated string
// and that individual keywords cannot contain whitespace
$myVideoEntry->SetVideoTags('cars, funny');
// set some developer tags -- this is optional
// (see Searching by Developer Tags for more details)
$myVideoEntry->setVideoDeveloperTags(array('mydevtag', 'anotherdevtag'));
// set the video's location -- this is also optional
$yt->registerPackage('Zend_Gdata_Geo');
$yt->registerPackage('Zend_Gdata_Geo_Extension');
$where = $yt->newGeoRssWhere();
$position = $yt->newGmlPos('37.0 -122.0');
$where->point = $yt->newGmlPoint($position);
$myVideoEntry->setWhere($where);
// upload URI for the currently authenticated user
$uploadUrl = 'http://uploads.gdata.youtube.com/feeds/api/users/default/uploads';
// try to upload the video, catching a Zend_Gdata_App_HttpException,
// if available, or just a regular Zend_Gdata_App_Exception otherwise
try {
$newEntry = $yt->insertEntry($myVideoEntry, $uploadUrl, 'Zend_Gdata_YouTube_VideoEntry');
} catch (Zend_Gdata_App_HttpException $httpException) {
echo $httpException->getRawResponseBody();
} catch (Zend_Gdata_App_Exception $e) {
echo $e->getMessage();
}
我尝试在以下几行中使用我的开发密钥,但是我需要把它放在哪里?
i try to use my devkey with the following lines, but where i need to put this?
$developerKey = 'ABC123 ... ';
$applicationId = 'Video uploader v1';
$clientId = 'My video upload client - v1';
$yt = new Zend_Gdata_YouTube($httpClient, $applicationId, $clientId, $developerKey);
我试图找到一个完整的 PHP 代码来将视频上传到 youtube,但没有找到任何东西........
i try to find a fully working PHP code to upload video to youtube, but dont find anything........
推荐答案
代替
$yt = new Zend_Gdata_YouTube($httpClient);
您需要执行以下操作:
$yt = new Zend_Gdata_YouTube($httpClient, $applicationId, $clientId, $developerKey);
请注意,$applicationId 和 $clientId 都必须是有效的 ID.除非已经可用,否则您可以在此处创建您的应用程序和客户端 ID:https://code.google.com/api/控制台/
Note that $applicationId and $clientId must each be valid ids. Unless already available, you can create your application and client ids here: https://code.google.com/apis/console/
您可以通过在此处注册来获取您的开发者密钥:https://code.google.com/apis/youtube/dashboard/gwt/index.html#settings
You can obtain your developer key by registering here: https://code.google.com/apis/youtube/dashboard/gwt/index.html#settings
这篇关于此操作所需的开发人员密钥的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!