Get 401 error when exchange request token and oauth verifier for an access token

After i use get_request_token function,i received two results are oauth_token and oauth_verifier. So continue,i use get_token for exchange an access_token but i get 401 error and i don't know the reason why. Here my code:

            $oauth_token=$_GET["oauth_token"];//get oauth_token from url
            $oauth_verifier=$_GET["oauth_verifier"];//get oauth_verifier from url
            $data = array(
                "oauth_nonce"               =>  random_string(),
                "oauth_timestamp"           =>  time(),
                "oauth_consumer_key"        =>  $this->config->item("consumerKey"),
                "oauth_signature_method"    =>  "PLAINTEXT",
                "oauth_signature"           =>  $this->config->item("consumerSecret")."&",
                "oauth_version"             =>  1.0,
                "oauth_token"               =>  $oauth_token,
                "oauth_verifier"            =>  $oauth_verifier
                "http"  =>  array(
                    "header"    =>  "Content-type: application/x-<www-form-urlencoded>\r\n",
                    "method"    =>  "POST",
                    "content"   =>  http_build_query($data)
            $context=  stream_context_create($options);

            $result = file_get_contents($url, false, $context);//get 401 error here!


Please help me

0 Replies

Recent Posts

in OAuth General Discussion YDN SDKs