public function getProgress($output_id) { $url = 'https://app.zencoder.com/api/outputs/' . $output_id . '/progress?api_key=' . $this->api_key; $curl = new CZenCoderCURL(); if (!$curl->get($url)) { return $curl->getError(); } // expected result // {"current_event":"Uploading","state":"finished"} $json = new CJSON(); $result = $json->decode($curl->getResults()); return $result; }
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); }