protected function TranscoderAbstractionFactoryZencoder::createUser in Video 7.2
Create Zencoder user account
1 call to TranscoderAbstractionFactoryZencoder::createUser()
- TranscoderAbstractionFactoryZencoder::adminSettingsValidate in transcoders/
TranscoderAbstractionFactoryZencoder.inc - Validate admin settings. This will call when Drupal admin settings validate.
File
- transcoders/
TranscoderAbstractionFactoryZencoder.inc, line 547 - File containing class TranscoderAbstractionFactoryZencoder
Class
- TranscoderAbstractionFactoryZencoder
- Class that handles Zencoder transcoding.
Code
protected function createUser($mail) {
libraries_load('zencoder');
$zencoder = new Services_Zencoder();
try {
// $result is Services_Zencoder_Account
$result = $zencoder->accounts
->create(array(
'terms_of_service' => '1',
'email' => $mail,
'affiliate_code' => 'drupal-video',
));
variable_set('video_zencoder_api_key', $result->api_key);
drupal_set_message(t('Your Zencoder details are as below.<br/><b>API Key</b> : @api_key<br/> <b>Password</b> : @password<br/> You can now login to the <a href="@zencoder-url">Zencoder website</a> and track your transcoding jobs online. Make sure you <b>save user/pass combination somewhere</b> before you proceed.', array(
'@api_key' => $result->api_key,
'@password' => $result->password,
'@zencoder-url' => url('http://zencoder.com'),
)), 'status');
return TRUE;
} catch (Services_Zencoder_Exception $e) {
if ($e
->getErrors() == NULL) {
return $e
->getMessage();
}
$errors = '';
foreach ($e
->getErrors() as $error) {
if ($error == 'Email has already been taken') {
drupal_set_message(t('Your account already exists on Zencoder. So <a href="@login-url">login</a> to here and enter a full access API key key below.', array(
'@login-url' => 'https://app.zencoder.com/api',
)));
variable_set('video_zencoder_api_key', t('Please enter your API key'));
return TRUE;
}
$errors .= $error;
}
return $errors;
}
}