Norbert Kiss
Norbert Kiss

Reputation: 273

How to get oauth_verification using PECL OAUTH?

I'm trying to get the verification code using php, but as I can see, there is only "manual" (I have to authorize manually) solution for this.

Is there any way to authorize your request token using pecl oauth? I see only getAccessToken and getRequestToken functions, there is nothing for authentication.

The following process requires the verification code at getAccessToken:

private function accessToken( $request_token, $request_token_secret ){
        $oauth = $this->oauth;
        $access_url = $this->access_url;
        $authorize_url = $this->authorize_url;
        $consumer_key = $this->consumer_key;
        $consumer_secret = $this->consumer_secret;

        try {
            $oauth = new OAuth( $consumer_key, $consumer_secret );
            $oauth->setToken( $request_token, $request_token_secret );

            $access_token_info = $oauth->getAccessToken( $access_url, null, VERIFICATION_CODE );

            if(!empty($access_token_info)) {
                //print_r($access_token_info);
                return $access_token_info;
            } else {
                print "Failed fetching access token, response was: " . $oauth->getLastResponse();
                return false;
            }
        } catch(OAuthException $E) {
            echo "Response: ". $E->lastResponse . "\n";
            return false;
        }
    } 

Upvotes: 1

Views: 34

Answers (0)

Related Questions