FatSecret Rest API と GTMOAuth を使用しようとしていますが、何が問題なのかわかりません。私が間違っていることを教えてくれる経験のある人はいますか?
私はObjective-Cが初めてなので、辛抱してください。
- (void)sendRequests4
{
NSString *consumerKey = @"my consumer key";
NSString *sharedSecret = @"my shared secret key";
RKClient *client = [RKClient sharedClient];
GTMOAuthAuthentication *auth = [[GTMOAuthAuthentication alloc]
initWithSignatureMethod:kGTMOAuthSignatureMethodHMAC_SHA1
consumerKey:client.OAuth1ConsumerKey
privateKey:client.OAuth1ConsumerSecret];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:client.baseURL];
auth.shouldUseParamsToAuthorize = YES;
[auth addAuthorizeTokenParamsToRequest:request];
[auth addAuthorizeTokenHeaderToRequest:request];
// Perform a simple HTTP GET and call me back with the results
NSMutableDictionary* params = [NSMutableDictionary dictionary];
[params setValue:consumerKey forKey:@"oauth_consumer_key"];
[params setValue:kGTMOAuthSignatureMethodHMAC_SHA1 forKey:@"oauth_signature_method"];
[params setValue:auth.timestamp forKey:@"oauth_timestamp"];
[params setValue:auth.nonce forKey:@"oauth_nonce"];
[params setValue:@"1.0" forKey:@"oauth_version"];
[params setValue:@"??????" forKey:@"oauth_signature"];
[params setValue:@"foods.get_most_eaten" forKey:@"method"];
[params setValue:@"??????" forKey:@"oauth_token"];
NSURL *url = [NSURL URLWithString:@"http://platform.fatsecret.com/rest/server.api"];
NSString *sigSecret = [NSString stringWithFormat:@"%@&", sharedSecret];
NSString *sig = [OAHMAC_SHA1SignatureProvider signature:params
AndURL:url
AndHTTPMethod:@"POST"
AndSignatureSecret:sigSecret];
NSString *encodedSignature = [sig urlEncodeUsingEncoding:NSUTF8StringEncoding];
[params setValue:encodedSignature forKey:@"oauth_signature"];
[client post:@"foods.get_most_eaten" params:params delegate:self];
}
どうもありがとう!