public function requestToken()
 {
     $request_token = new DTOAuthToken(array("consumer_id" => $this->consumer_id));
     // OAuth 1.0a sets the callback here, which we need to use after authentication
     $headers = getallheaders();
     $auth_header = $headers["Authorization"];
     /// @todo: make this case-insensitive
     $oauth = substr($auth_header, 6);
     $opts = explode(",", $oauth);
     foreach ($opts as $opt) {
         preg_match("/(.*)\\=\"(.*)\"/", $opt, $matches);
         $k = $matches[1];
         $v = $matches[2];
         if ($k == "oauth_callback") {
             $request_token["oauth_callback"] = urldecode($v);
         }
     }
     $request_token->insert($this->db);
     exit("oauth_token={$request_token["token"]}" . "&oauth_token_secret={$request_token["secret"]}" . "&oauth_callback_confirmed=true" . "&login_url={$this->auth_url}");
 }
 public function requestToken()
 {
     $request_token = new DTOAuthToken(array("consumer_id" => $this->consumer_id));
     // OAuth 1.0a sets the callback here, which we need to use after authentication
     $headers = $this->getAllHeaders();
     $auth_header = $headers["authorization"];
     $oauth = substr($auth_header, 6);
     $opts = explode(",", $oauth);
     foreach ($opts as $opt) {
         preg_match("/(.*)\\=\"(.*)\"/", $opt, $matches);
         $k = $matches[1];
         $v = $matches[2];
         if ($k == "oauth_callback") {
             //this only happens for custom callbacks
             if (!in_array("oauth_callback", $this->db->columnsForTable(DTOAuthToken::$storage_table))) {
                 DTLog::error("OAuth-Callback specified but not stored. Please add the column oauth_callback::text to the " . DTOAuthToken::$storage_table . " table.");
             }
             $request_token["oauth_callback"] = urldecode($v);
         }
     }
     $request_token->insert($this->db);
     exit("oauth_token={$request_token["token"]}" . "&oauth_token_secret={$request_token["secret"]}" . "&oauth_callback_confirmed=true" . "&login_url={$this->auth_url}");
 }