/** * Update the presentation with ID provided to the attributes provided * * @param int $id * @param array $attributes */ public static function update($asset_type, $id, $attributes, $token_value, $token_secret) { #TODO: Check if token value/secret is null and if so try to retrieve from VJ (Videojuicer::get_access_token()->get_token(), Videojuicer::get_access_token()->get_secret()) $method = "assets/{$asset_type}/{$id}"; $type = Videojuicer_Request::PUT; $response_class = "Videojuicer_Asset_" . ucfirst($asset_type) . "_Update_Response"; $exception_class = "Videojuicer_Asset_" . ucfirst($asset_type) . "_Update_Exception"; $permission = Videojuicer_Permission::WRITE_USER; $attributes = Videojuicer_Request::wrap_vars($attributes, "asset"); $request = new Videojuicer_Request($method, $type, $permission, $response_class, $exception_class); $request->set_vars($attributes); $request->set_authorized(true, $token_value, $token_secret); return Videojuicer::execute_call($request); }
/** * Get all presentations, optinally meeting the required criteria * * @param array $criteria Find only presentations which meet the criteria provided * @return Videojuicer_Presentation_List_Response */ public function find_all($criteria = array()) { $method = "presentations"; $type = Videojuicer_Request::GET; $response_class = "Videojuicer_Presentation_List_Response"; $exception_class = "Videojuicer_Presentation_List_Exception"; $permission = Videojuicer_Permission::NONE; $request = new Videojuicer_Request($method, $type, $permission, $response_class, $exception_class); // Wrap each of the criteria with a presentation key $converted_criteria = array(); foreach ($criteria as $k => $v) { $converted_criteria["presentation[{$k}]"] = $v; } $request->set_vars($converted_criteria); return Videojuicer::execute_call($request); }
public static function execute_call(Videojuicer_Request $req) { // Do the logic to decide what the components of the HTTP request should be $helper = new Videojuicer_Call_Helper($req); $helper->setup_components(); // Retrieve the values determined $url = $helper->get_url(); $post_vars = $helper->get_post_vars(); $type = $req->get_safe_type(); $file = $req->get_upload_file_path(); // Get the resulting xml(or other data) $data = self::execute_call_curl($url, $req->get_type(), $post_vars, $file); // Convert the xml to the target class $response_class = $req->get_response_class(); Videojuicer_ClassLoader::load($response_class); $result = new $response_class($data); // Return the result return $result; }
/** * Retrieve an authorized request token in preperation for retrieving an access token */ public static function get_authorized_request_token($unauthorized_token_value = null, $unauthorized_token_secret = null) { // If we weren't given a token to use, retrieve it from Videojuicer class if (is_null($unauthorized_token_value) || is_null($unauthorized_token_secret)) { $token = Videojuicer::get_token(); if ($token instanceof Videojuicer_Token_Unauthorized) { $unauthorized_token_value = $token->get_token(); $unauthorized_token_secret = $token->get_secret(); } } $method = "oauth/tokens"; $type = Videojuicer_Request::GET; $response_class = "Videojuicer_Token_Authorized_Response"; $exception_class = "Videojuicer_Token_Authorized_Exception"; $permission = Videojuicer_Permission::NONE; $request = new Videojuicer_Request($method, $type, $permission, $response_class, $exception_class); $request->set_authorized(true, $unauthorized_token_value, $unauthorized_token_secret); $request->use_extension(false); return Videojuicer::execute_call($request); }
/** * Update the presentation with ID provided to the attributes provided * * @param int $id * @param array $attributes */ public static function delete($id, $token_value, $token_secret) { #TODO: Check if token value/secret is null and if so try to retrieve from VJ (Videojuicer::get_access_token()->get_token(), Videojuicer::get_access_token()->get_secret()) $method = "presentations/{$id}"; $type = Videojuicer_Request::DELETE; $response_class = "Videojuicer_Presentation_Delete_Response"; $exception_class = "Videojuicer_Presentation_Delete_Exception"; $permission = Videojuicer_Permission::WRITE_USER; $request = new Videojuicer_Request($method, $type, $permission, $response_class, $exception_class); $request->set_authorized(true, $token_value, $token_secret); return Videojuicer::execute_call($request); }
public static function remove_role($id, $role, $token_value, $token_secret) { #TODO: Check if token value/secret is null and if so try to retrieve from VJ (Videojuicer::get_access_token()->get_token(), Videojuicer::get_access_token()->get_secret()) $method = "users/{$id}/remove_role"; $type = Videojuicer_Request::POST; $response_class = "Videojuicer_User_RemoveRole_Response"; $exception_class = "Videojuicer_User_RemoveRole_Exception"; $permission = Videojuicer_Permission::NONE; $attributes = array("role" => $role); $request = new Videojuicer_Request($method, $type, $permission, $response_class, $exception_class); $request->set_authorized(true, $token_value, $token_secret); $request->set_vars($attributes); return Videojuicer::execute_call($request); }