Example #1
0
 /**
  * Constructor will either restore authenticated state (setting authenticated to true if auth token is given) or initialize the login parms to empty
  * Do not call the constructor with login parameters, use Authenticate() instead
  * @param string $authstate - optional, if provided it should be from GetState when authenticated is true
  */
 public function __construct()
 {
     $authstate = func_get_args();
     if ($authstate && is_array(current($authstate))) {
         $authstate = array_shift($authstate);
     }
     if ($authstate) {
         $this->RestoreState($authstate);
     }
     if (!$this->Authenticated()) {
         $this->Reset();
         $this->SetSource(isset($_SERVER["HTTP_HOST"]) ? $_SERVER["HTTP_HOST"] : "Unknown");
     }
     parent::__construct();
 }
Example #2
0
 /**
  * Intercept set request options to add cookies for the current request
  */
 protected function set_request_options()
 {
     # __next_location is the effective request url
     if ($cookie = $this->get_cookie($this->__next_location)) {
         $this->__curl_opts[CURLOPT_COOKIE] = $cookie;
     }
     parent::set_request_options();
 }
Example #3
0
 protected function set_request_options()
 {
     $data = $this->__url_encoded_data ? $this->__url_encoded_data : array();
     $query = $this->__request_query_parms ? $this->__request_query_parms : array();
     $auth = $this->base_auth_parms();
     if ($this->request_headers && isset($this->request_headers[$this->auth_header_name])) {
         unset($this->request_headers[$this->auth_header_name]);
     }
     $base_url_array = array_map("strtolower", $this->__request_url_parts);
     if (isset($base_url_array["path"])) {
         $base_url_array["path"] = $this->__request_url_parts["path"];
     }
     $base_url = SPUtils::url_from_parts($base_url_array);
     $base_parm_string = SPOAuthClient::construct_base_string(SPUtils::array_map_assoc($this->__encoding_callback, $query, $data, $auth));
     $this->oauth_signature = SPOAuthClient::sign_base_string($this->oauth_signature_method, SPUtils::join_encoded3896($this->__request_http_method, $base_url, $base_parm_string), $this->oauth_consumer_secret, $this->oauth_token_secret);
     $auth["oauth_signature"] = $this->oauth_signature;
     switch ($this->auth_http_method) {
         case SPConstants::HTTP_METHOD_GET:
             $query = array_merge($query, $auth);
             break;
         case SPConstants::HTTP_METHOD_POST:
             $data = array_merge($data, $auth);
             $this->CURLOPT_POSTFIELDS = SPUtils::join_key_values_assoc("=", "&", SPUtils::array_map_assoc($this->__encoding_callback, $data));
             break;
         case SPOAuthClient::HTTP_AUTH_HEADER:
             $this->request_headers[$this->auth_header_name] = $this->get_auth_header(SPUtils::array_map_assoc($this->__encoding_callback, $auth));
             break;
     }
     $this->__request_query_parms = $query;
     parent::set_request_options();
 }