public function create($input, $output, $test = false, $region = null, $download_connections = null) { $params = $this->_build($input, $output, $test, $region, $download_connections); $json = new CJSON(); $params = $json->encode($params); $curl = new CZenCoderCURL(); if (!$curl->post($this->jobUrl, $params)) { $this->setError($curl->getError()); return false; } $result = $curl->getResults(); $result = $json->decode($result); if (isset($result->errors)) { $this->setError($result->errors[0]); return false; } return true; }
public function ajaxSubmitForm($form = null) { if (!is_array($form)) { return false; } // validation if (!$form['email']) { $form['_error'] = 'You need to enter an email'; $this->ajaxShowForm($form); } if ($form['password'] == '' || $form['password'] !== $form['password2']) { $form['_error'] = 'Password empty or do not match'; $this->ajaxShowForm($form); } if (!isset($form['terms_of_service'])) { $form['_error'] = 'You did not agree to the Term of Service'; $this->ajaxShowForm($form); } $data = array('terms_of_service' => 0, 'email' => '', 'password' => '', 'affiliate_code' => 'jomsocial', 'newsletter' => 0); // something is weird with the returning value of jax.getFormValues // we can't use array_merge here :( //array_merge($form, $values); $data['email'] = $form['email']; $data['password'] = $form['password2']; $data['terms_of_service'] = $form['terms_of_service']; $data = json_encode($data); CFactory::load('libraries', 'zencoder'); $curl = new CZenCoderCURL(); if (!$curl->post('https://app.zencoder.com/api/account', $data)) { $this->ajaxShowSuccss($curl->getError()); } $content = ''; $code = $curl->getStatusCode(); $result = $curl->getResults(); $result = json_decode($result); if (isset($result->errors)) { foreach ($result->errors as $error) { $content .= $error . '<br />'; } } if (isset($result->api_key)) { $content .= 'Your API key: ' . $result->api_key . '<br />'; $content .= 'Password: '******'configuration', 'CommunityTable'); $config->load('config'); $params = new CParameter($config->params); $params->set('zencoder_api_key', $result->api_key); $config->params = $params->toString(); $config->store(); } if (!isset($result->errors) && !isset($result->api_key)) { $content = 'Something is wrong here...'; } $this->ajaxShowSuccss($content); }