twitter分享问题(三)——Required oauth_verifier parameter not provided

     使用shareKit做twitter分享,遇到如下错误:

twitter分享问题(三)——Required oauth_verifier parameter not provided_第1张图片

       “There was a problem requesting access from Twitter”,打个断点,跟踪到“SHKOAuthSharer.m”的这个函数:

- (void)tokenAccessTicket:(OAServiceTicket *)ticket didFinishWithData:(NSData *)data   

       看下打印的信息:

TwitterShareDemo[7111:c07] tokenAccessTicket Response Body: <?xml version="1.0" encoding="UTF-8"?>  
<hash>  
  <request>/oauth/access_token</request>  
  <error>Required oauth_verifier parameter not provided</error>  
</hash> 
      即参数“oauth_verifier”丢失,我去twitter查了下,说是在api 1.0的时候,授权请求时这个参数可有可无,但是到了api 1.0a的时候是必须强制带上的,故需要添加这个参数,修改位置:“SHKOAuthSharer.m”,如下

- (void)tokenAccess:(BOOL)refresh
{
	if (!refresh)
		[[SHKActivityIndicator currentIndicator] displayActivity:SHKLocalizedString(@"Authenticating...")];
	
    NSString *oauth_verifier = [self.authorizeResponseQueryVars objectForKey:@"oauth_verifier"];
	NSString *urlStr = [@"https://api.twitter.com/oauth/access_token" stringByAppendingFormat:@"?oauth_verifier=%@",oauth_verifier];
    NSURL *url = [NSURL URLWithString:urlStr];
    OAMutableURLRequest *oRequest = [[OAMutableURLRequest alloc] initWithURL:url
                                                                    consumer:consumer
																	   token:(refresh ? accessToken : requestToken)
                                                                       realm:nil   // our service provider doesn't specify a realm
                                                           signatureProvider:signatureProvider]; // use the default method, HMAC-SHA1
    
//    OAMutableURLRequest *oRequest = [[OAMutableURLRequest alloc] initWithURL:accessURL
//                                                                   consumer:consumer
//																	   token:(refresh ? accessToken : requestToken)
//                                                                      realm:nil   // our service provider doesn't specify a realm
//                                                          signatureProvider:signatureProvider]; // use the default method, HMAC-SHA1
	
    [oRequest setHTTPMethod:@"POST"];
	
	[self tokenAccessModifyRequest:oRequest];
	
    OAAsynchronousDataFetcher *fetcher = [OAAsynchronousDataFetcher asynchronousFetcherWithRequest:oRequest
                         delegate:self
                didFinishSelector:@selector(tokenAccessTicket:didFinishWithData:)
                  didFailSelector:@selector(tokenAccessTicket:didFailWithError:)];
	[fetcher start];
	[oRequest release];
}

   完工~



你可能感兴趣的:(oauth_verifier,twitter分享)