Hi,
I am sudhakar using your fatsecret api. Currently i am having the
problem in the "3-Legged OAuth Authentication" Its the three step
process.
Step1: Obtaining a Request Token
In this step we used the function GetRequestToken() using the
requet url
http://www.fatsecret.com/oauth/request_token
and initially in the HTTP Method we used the POST method due to
this resulted the ERROR: "Invalid signature". Later we went through
the artice and chnaged the method to GET and we got the result.
oauth_token=xxxxxxxxxx ,
oauth_token_secret=xxxxxxxxxx ,oauth_callback_confirmed=true
Step2: Obtaining User Authorization
In the method we used the url
http://www.fatsecret.com/oauth/authorize
and the oauth_token obtained in the First Step.
In this step also we got the result oauth_token = The Request Token
that the User authorized and the oauth_verifier = The verification
code.
Step3: Obtaining an Access Token
Getting ERROR "Invalid signature" in this step we tried using
both the GET or the POST method but we are getting the error.
This is the methods we are passing
http://www.fatsecret.com/oauth/access_token?oauth_consumer_key=2faf4ae732034c55a30761bc53e891dc&oauth_nonce=65852d8e86fca96f8eb8e08312e78e3f&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1333186119&oauth_version=1.0&oauth_signature=ynXuaQPoc1FK%2BDZMhio%2FG9t7BGw%3D&oauth_token=7abc47163fe74fadb171792e2e76efdc&oauth_verifier=6344836
We have send all the information required but still its generating the
error "Invalid signature".
Does i am wrong in sending the information?.
Function Used:
-------------------------
function GetAuthTokenUsingMethod2($oauth_token,$oauth_verifier) {
$url = '
http://www.fatsecret.com/oauth/access_token';
$oauth = new OAuthBase();
$normalizedUrl;
$normalizedRequestParameters;
$signature = $oauth->GenerateGetSignature($url, $this-
>_consumerKey,$this->_consumerSecret, NULL, NULL, $normalizedUrl,
$normalizedRequestParameters);
$postString = $normalizedRequestParameters . '&' . OAuthBase::
$OAUTH_SIGNATURE .'='.urlencode($signature).'&oauth_token='.urlencode($oauth_token).'&oauth_verifier='.urlencode($oauth_verifier);
print("<PRE>");
print_r($normalizedUrl.$postString);
return $this->GetQueryResponse($normalizedUrl, $postString);
}
Function used to create signature:
--------------------------------------------------
function GenerateSignature($url, $consumerKey, $consumerSecret,
$token, $tokenSecret, &$normalizedUrl, &$normalizedRequestParameters){
$signatureBase = $this->GenerateSignatureBase($url, $consumerKey,
$token, 'POST', $this->GenerateTimeStamp(), $this->GenerateNonce(),
'HMAC-SHA1', $normalizedUrl, $normalizedRequestParameters);
$secretKey = $this->UrlEncode($consumerSecret) . '&' . $this-
>UrlEncode($tokenSecret);
return base64_encode(hash_hmac('sha1', $signatureBase, $secretKey,
true));
}
Please check the functions and methods and help me how to solve the
problem and to sucess in the Third Step to get the oauth_token and
oauth_token_secret keys.
Thanks,
Sudhakar.