iphone - How to integrate Vimeo in IOS? -
i integrate vimeo in app.i had gone through vimeo developer site.every thing ok unable authenticate.i had gone through oauth tutorial,but found difficulty in understanding.my deadline short.i found link not felt easy , good.if 1 had worked on it,please guide me.
at first dragged oauthconsumer files in project
http://oauth.googlecode.com/svn/code/obj-c/oauthconsumer/
"iphone ready" means need add files xcode, , import "oauthconsumer.h".
if you're rolling iphone:
1) sure add security.framework.
2) include libxml2.dylib in frameworks. need add build property project -- "header search paths" needs include "$sdkroot/usr/include/libxml2" "recursive" checked.
in viewcontroller.h
#import "oaconsumer.h" #import "oamutableurlrequest.h" #import "oadatafetcher.h" @property(nonatomic,strong) oatoken *accesstoken; @property(nonatomic,strong) iboutlet uiwebview *webview;
in viewcontroller.m
@synthesize accesstoken; @synthesize webview; - (void)viewdidload { [super viewdidload]; // additional setup after loading view, typically nib. // additional setup after loading view, typically nib. oaconsumer *consumer = [[oaconsumer alloc] initwithkey:@"fa9374b9fc90f2ffd7b4p8k3776530fa6023985b" secret:@"d6242b63d435757526u87e7ceca98ffdcd8d9d55e"]; 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); } }
Comments
Post a Comment