Reputation: 57
i am using vimeo advance api for searching videos against query like in youtube and daily motion. vimeo advance api require oauth authentication . i want that vimeo return me json like the vimeo playground . https://developer.vimeo.com/apis/advanced/methods/vimeo.videos.search/playground . i write the following code to get json data but no idea who i get json data
- (void)viewDidLoad
{
[super viewDidLoad];
SBJsonParser *json = [[SBJsonParser alloc]init];
// Do any additional setup after loading the view, typically from a nib.
OAConsumer *consumer = [[OAConsumer alloc] initWithKey:@"0c5e6dd9b8fa5f8d91563332da03912ac8c2e15d"
secret:@"744eb15d911ee3607f7006f1f4ad7eb17a94eec6"];
NSURL *url = [NSURL URLWithString:@"https://vimeo.com/oauth/request_token"];
OAMutableURLRequest *request = [[OAMutableURLRequest alloc] initWithURL:url
consumer:consumer
token:nil
realm:nil
signatureProvider:nil];
[request setParameters: [NSArray arrayWithObjects: [[OARequestParameter alloc] initWithName: @"oauth_callback" value: @"http://vimeo.com/api/rest/v2?format=json&method=vimeo.videos.search&qdfduery=amir+khan"] ,nil]];
[request setHTTPMethod:@"GET"];
OADataFetcher *fetcher = [[OADataFetcher alloc] init];
[fetcher fetchDataWithRequest:request
delegate:self
didFinishSelector:@selector(requestTokenTicket:didFinishWithData:)
didFailSelector:nil];
}
- (void)requestTokenTicket:(OAServiceTicket *)ticket didFinishWithData:(NSData *)data {
if (ticket.didSucceed)
{
NSString *responseBody = [[NSString alloc] initWithData:data
encoding:NSUTF8StringEncoding];
OAToken *requestToken = [[OAToken alloc] initWithHTTPResponseBody:responseBody];
NSLog(@"data %@",requestToken);
OAMutableURLRequest *request;
if (self.accessToken != nil) {
self.accessToken = nil;
}
self.accessToken = [[OAToken alloc] initWithHTTPResponseBody:responseBody];
NSLog(@"access token key %@",self.accessToken.key) ;
NSLog(@"access token secret %@",self.accessToken.secret) ;
NSURL *url = [NSURL URLWithString:@"https://vimeo.com/oauth/authorize"];
OAConsumer *consumer = [[OAConsumer alloc] initWithKey:self.accessToken.key
secret:self.accessToken.secret];
request = [[OAMutableURLRequest alloc] initWithURL:url
consumer:consumer
token:self.accessToken
realm:nil
signatureProvider:nil];
OARequestParameter *p0 = [[OARequestParameter alloc] initWithName:@"oauth_token" value:self.accessToken.key];
NSArray *params = [NSArray arrayWithObject:p0];
[request setParameters:params];
[webView loadRequest:request];
NSLog(@"request %@",request);
}
}
the above code return me access token . but i don't know how i can use that access token to get json like in vimeo playground . kindly anybody complete it for me i am so confused because on vimeo site their is no proper guideline how do i use advance api
Upvotes: 0
Views: 795
Reputation: 3998
Once you have an access token you need to make an authenticated request against the "http://vimeo.com/api/rest/v2" endpoint.
This request must follow the same oauth 1.0a signing process you performed while retrieving the oauth token.
You must also provide an api method via the querystring parameter, so to search for videos you would provide method=vimeo.videos.search. You can see an example of this on the playground under the "Request" header.
Any other parameters (such as format=json) are also handled via the querystring.
Upvotes: 1