朋友您好我正在使用oauth
登录tumblr我的问题是我在oauth的第一步中遇到了这个错误
oauth_signature与期望值
不匹配我正在使用oauth 1.0库
这是我的第一部分代码
(void)viewDidLoad { [super viewDidLoad];
clientID = @“zKJI0u2qC4u9fZzSzDNit289fjYy7zytDevTD0zv1QWzxqSUcb”; secret = @“P0cJxrFiSPAMHMsLIPTQQf7nGQDDCpDpAP9syWeRhcDrresoyW”;
redirect = @“http://codegerms.com/”;
[self connectTumblr];
}
- (void)connectTumblr {
consumer = [[OAConsumer alloc]initWithKey:clientID secret:nil];
NSURL* requestTokenUrl = [NSURL URLWithString:@"http://www.tumblr.com/oauth/request_token"];
OAMutableURLRequest* requestTokenRequest = [[OAMutableURLRequest alloc] initWithURL:requestTokenUrl consumer:consumer token:nil realm:nil signatureProvider:nil nonce:nil timestamp:@"1416360846"];
OARequestParameter* callbackParam = [[OARequestParameter alloc] initWithName:@"oauth_callback" value:redirect] ;
[requestTokenRequest setHTTPMethod:@"POST"];
[requestTokenRequest setParameters:[NSArray arrayWithObject:callbackParam]];
OADataFetcher* dataFetcher = [[OADataFetcher alloc] init] ;
[dataFetcher fetchDataWithRequest:requestTokenRequest
delegate:self
didFinishSelector:@selector(didReceiveRequestToken:data:)
didFailSelector:@selector(didFailOAuth:error:)];
} - (无效)didFailOAuth:(的NSString *)错误 {
}
(void)didReceiveRequestToken :( OAServiceTicket *)故障单数据:(NSData *)数据{
NSString * httpBody = [[NSString alloc] initWithData:数据编码:NSUTF8StringEncoding];
requestToken = [[OAToken alloc] initWithHTTPResponseBody:httpBody];
NSURL * authorizeUrl = [NSURL URLWithString:@“https://www.tumblr.com/oauth/authorize”];
OAMutableURLRequest * authorizeRequest = [[OAMutableURLRequest alloc] initWithURL:authorizeUrl
consumer:nil
token:nil
realm:nil
signatureProvider:nil];
NSString * oauthToken = requestToken.key;
OARequestParameter * oauthTokenParam = [[OARequestParameter alloc] initWithName:@“oauth_token”value:oauthToken];
[authorizeRequest setParameters:[NSArray arrayWithObject:oauthTokenParam]];
[WebView loadRequest:authorizeRequest];
}
现在我该如何解决这个问题呢?
我使用的方法与Twitter相同但不适用于Tumblr
另外,我手动尝试创建URL,但它也无法正常工作
请帮帮我:(
我做了很多搜索,但发现了可靠的答案