/**
  * Sign a request
  *
  * Returned is an array with multiple values
  * the response['success'] is a boolean to indicate a failure
  * the response['message'] is a description of any failures
  * the response['url'] is the signed url
  *
  * @param string - url to request
  * @param array - the parameters
  * @param string - the http method
  * @return array
  */
 private function sign_oauth_request($url, $params, $method)
 {
     $response = array('success' => false, 'url' => '', 'message' => '');
     try {
         $consumer = new echo360_oauth_consumer($this->consumerkey, $this->consumersecret, NULL);
         // empty token for 2 legged oauth
         $oauthrequest = echo360_oauth_request::from_consumer_and_token($consumer, new echo360_oauth_token('', ''), $method, $url, $params);
         $oauthrequest->sign_request(new echo360_oauth_signature_method_hmacsha1(), $consumer, NULL);
         $url = $oauthrequest->to_url();
         $response['success'] = true;
         $response['message'] = 'success';
         $response['url'] = $url;
     } catch (Exception $e) {
         $response['success'] = false;
         $response['message'] = print_r($e);
         $response['url'] = '';
     }
     return $response;
 }
 /**
  * Pretty much a helper function to set up the request
  *
  * @param echo360_oauth_consumer - Contains the OAuth secret and key
  * @param echo360_oauth_token    - The token for the request (can be null)
  * @param string                 - "GET|POST|DELETE|PUT" (for REST)
  * @param string                 - The URL of the request
  * @param array                  - Array of parameters for the request
  * @return echo360_oauth_request
  */
 public static function from_consumer_and_token($consumer, $token, $http_method, $http_url, $parameters = NULL)
 {
     @$parameters or $parameters = array();
     $defaults = array("oauth_version" => echo360_oauth_request::$version, "oauth_nonce" => echo360_oauth_request::generate_nonce(), "oauth_timestamp" => echo360_oauth_request::generate_timestamp(), "oauth_consumer_key" => $consumer->key);
     $parameters = array_merge($defaults, $parameters);
     if ($token) {
         $parameters['oauth_token'] = $token->key;
     }
     return new echo360_oauth_request($http_method, $http_url, $parameters);
 }