public function video_zencoder_api::create_user in Video 7
Same name and namespace in other branches
- 6.5 plugins/video_zencoder/video_zencoder.lib.inc \video_zencoder_api::create_user()
- 6.4 plugins/video_zencoder/video_zencoder.lib.inc \video_zencoder_api::create_user()
Create Zencoder user account
File
- modules/
video_zencoder/ includes/ zencoder.inc, line 209
Class
Code
public function create_user($user) {
$request = new ZencoderRequest('https://app.zencoder.com/api/account', FALSE, array(
"terms_of_service" => "1",
"email" => $user->email,
"affiliate_code" => "drupal-video",
));
if ($request->successful) {
$results = $request->results;
variable_set('video_zencoder_api_key', $results['api_key']);
$message = drupal_mail('video_zencoder', 'video_zencoder', $user->email, language_default(), $results);
if (!$message['result']) {
drupal_set_message(t('Unable to send e-mail!. Your Zencoder Details are as below.<br/> <b>API Key</b> : !api_key<br/> <b>Password</b> : !password<br/>', array(
'!api_key' => $results['api_key'],
'!password' => $results['password'],
)), 'status');
}
else {
// drupal_mail('video_zencoder', 'video_zencoder', 'heshanmw@gmail.com', language_default(), $results);
drupal_set_message(t('Your account has been created and is ready to start processing on Zencoder'));
}
// return $request->results;
return TRUE;
// variable_set('video_zencoder_api_key', '');
}
else {
$errors = '';
foreach ($request->errors as $error) {
if ($error == 'Email has already been taken') {
drupal_set_message(t('Your account already exists on Zencoder. So !login to here and enter API key below', array(
'!login' => l(t('login'), 'https://app.zencoder.com/session/new'),
)));
variable_set('video_zencoder_api_key', 'Please enter your API Key');
return TRUE;
}
$errors .= $error;
}
return $errors;
}
}