function _video_upload_gdata_authenticate_youtube in Video 6.2
Authenticate YouTube user account.
File
- includes/
apiclient.inc, line 27 - Some functions for using video hosting providers api (Youtube, Google Video, etc..) Part of this code has been inspired by the video_cck module and adapted for the video module by jyamada1
Code
function _video_upload_gdata_authenticate_youtube() {
// Username.
// $username = variable_get('video_upload_youtube_username', FALSE);
$username = 'heshanmw';
if (!$username) {
watchdog('video_upload', 'No YouTube username set', array(), WATCHDOG_ERROR);
}
// Password.
// $password = variable_get('video_upload_youtube_password', FALSE);
$password = 'chicagobulls';
if (!$password) {
watchdog('video_upload', 'No YouTube password set', array(), WATCHDOG_ERROR);
}
if (!$username || !$password) {
drupal_set_message(t('YouTube Uploads not currently available'), 'error');
return FALSE;
}
if (_video_apiclient_youtube_init('authenticate')) {
try {
$http_client = Zend_Gdata_ClientLogin::getHttpClient($username, $password, $service = 'youtube', $client = NULL, $source = 'drupal', $loginToken = NULL, $loginCaptcha = NULL, VIDEO_UPLOAD_GDATA_AUTHENTICATE_URL);
} catch (Zend_Gdata_App_AuthException $authEx) {
drupal_set_message(t('YouTube uploads currently unavailable'), 'error');
watchdog('video_upload', 'Authentication error for YouTube Account', array(), WATCHDOG_ERROR);
return FALSE;
} catch (Zend_Gdata_App_HttpException $e) {
drupal_set_message(t('YouTube uploads currently unavailable'), 'error');
watchdog('video_upload', 'Authentication error for YouTube Account: %error', array(
'%error' => $e
->getMessage(),
), WATCHDOG_ERROR);
return FALSE;
}
}
else {
return FALSE;
}
// Pass developer key.
// $developer_key = variable_get('video_upload_youtube_developer_key', FALSE);
$developer_key = variable_get('video_youtube_api_key', '');
if (!$developer_key) {
watchdog('video_upload', 'No developer key set', array(), WATCHDOG_ERROR);
drupal_set_message(t('YouTube Uploads not currently available'), 'error');
return FALSE;
}
$http_client
->setHeaders('X-GData-Key', 'key=' . $developer_key);
return $http_client;
}