Пример #1
0
 /**
  * Send the user to the authorisation page and redirect to the callback page on completion
  * 
  * @param string $callback_url The url to redirect the user to once they're logged in at Videojuicer
  * @param string $unauthorized_token_value The token value to use when signning the request (optional: if no value passed, the current one is retrieved from the Videojuicer class)
  */
 public static function get_authorize_url($callback_url, $unauthorized_token_value = null)
 {
     // If we weren't given a token to use, retrieve it from Videojuicer class
     if (is_null($unauthorized_token_value)) {
         $token = Videojuicer::get_token();
         if ($token instanceof Videojuicer_Token_Unauthorized) {
             $unauthorized_token_value = $token->get_token();
         }
     }
     $method = "oauth/tokens/new";
     $type = Videojuicer_Request::GET;
     $response_class = "Videojuicer_Token_Authorize_Response";
     $exception_class = "Videojuicer_Token_Authorize_Exception";
     $permission = Videojuicer_Permission::NONE;
     $request = new Videojuicer_Request($method, $type, $permission, $response_class, $exception_class);
     $request->set_authorized(true, $unauthorized_token_value);
     $request->set_vars(array("oauth_callback" => $callback_url));
     $request->use_extension(false);
     // Do the logic to decide what the components of the HTTP request should be
     Videojuicer_ClassLoader::load("Videojuicer_Call_Helper");
     $helper = new Videojuicer_Call_Helper($request);
     $helper->setup_components();
     // Retrieve the values determined
     $url = $helper->get_url();
     return $url;
 }
Пример #2
0
 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;
 }