Iphone 访问vimeo高级api时出错
在获取vimeo高级搜索api时,我以json格式获取此错误。这就是错误Iphone 访问vimeo高级api时出错,iphone,objective-c,vimeo,Iphone,Objective C,Vimeo,在获取vimeo高级搜索api时,我以json格式获取此错误。这就是错误 {"code":"401","expl":"The oauth_token passed has not been authorized by the user.","msg":"Invalid token"}} 这是我在vimeo上进行身份验证的代码 - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after l
{"code":"401","expl":"The oauth_token passed has not been authorized by the user.","msg":"Invalid token"}}
这是我在vimeo上进行身份验证的代码
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
consumer = [[OAConsumer alloc] initWithKey:@"xxxxxxxxxxxx"
secret:@"xxxxxxxxxxxx"];
NSURL *url = [NSURL URLWithString:@"https://vimeo.com/oauth/request_token"];
OAMutableURLRequest *request = [[OAMutableURLRequest alloc] initWithURL:url
consumer:consumer
token:nil // we don't have a Token yet
realm:nil // our service provider doesn't specify a realm
signatureProvider:nil]; // use the default method, HMAC-SHA1
[request setParameters: [NSArray arrayWithObjects: [[OARequestParameter alloc] initWithName: @"oauth_callback" value: @"http://iosdevelopertips.com/networking/iphone-json-flickr-tutorial-part-1.html"] ,nil]];
[request setHTTPMethod:@"GET"];
OADataFetcher *fetcher = [[OADataFetcher alloc] init];
[fetcher fetchDataWithRequest:request
delegate:self
didFinishSelector:@selector(requestTokenTicket:didFinishWithData:)
didFailSelector:@selector(requestTokenTicket:didFailWithError:)];
}
- (void)requestTokenTicket:(OAServiceTicket *)ticket didFinishWithData:(NSData *)data {
NSLog(@"ticket value %@",ticket);
if (ticket.didSucceed) {
NSString *responseBody = [[NSString alloc] initWithData:data
encoding:NSUTF8StringEncoding];
requestToken = [[OAToken alloc] initWithHTTPResponseBody:responseBody];
}
NSString *urlString = [NSString stringWithFormat:@"https://vimeo.com/oauth/authorize?auth_token=%@", requestToken.key];
NSURL *urlAuth = [NSURL URLWithString:urlString];
[[UIApplication sharedApplication] openURL:urlAuth];
NSURL *url = [NSURL URLWithString:@"http://vimeo.com/api/rest/v2?method=vimeo.videos.search"];
OAMutableURLRequest *request = [[OAMutableURLRequest alloc] initWithURL:url
consumer:consumer
token:requestToken
realm:nil
signatureProvider:[[OAHMAC_SHA1SignatureProvider alloc] init]];
OARequestParameter *nameParam = [[OARequestParameter alloc] initWithName:@"format"
value:@"json"];
OARequestParameter *descParam = [[OARequestParameter alloc] initWithName:@"query"
value:@"amir khan"];
NSArray *params = [NSArray arrayWithObjects:nameParam, descParam, nil];
[request setParameters:params];
OADataFetcher *fetcher = [[OADataFetcher alloc] init];
[fetcher fetchDataWithRequest:request
delegate:self
didFinishSelector:@selector(requestTokenTicket2:didFinishWithData:)
didFailSelector:@selector(requestTokenTicket2:didFinishWithData:)];
}
- (void)requestTokenTicket2:(OAServiceTicket *)ticket didFinishWithData:(NSData *)data
{
NSString *dataString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSLog(@"data string %@",dataString);
}
错误消息“用户未授权传递的oauth_令牌”表示您正在使用请求令牌,而不是访问令牌
请求令牌是用户使用应用程序进行身份验证之前获得的令牌。
此令牌用于构建将用户发送到的url
一旦用户在vimeo.com上批准了您的应用程序,他们将被重定向到您的应用程序。此时,您应该将您的请求令牌交换为访问令牌。旁注:永远不要向公众显示您的凭据。您是否知道问题出在哪里?您好,您知道答案了吗?