Ios 在iphone中获取yahoo联系人
我下面的链接:用于检索雅虎联系人 在提供所有凭据(即密钥、消费者密钥、应用程序id)后,它将进入浏览器进行登录。但登录后,它会显示以下消息: 完成雅虎的分享!带有xxxx的信息,在xxxx中输入代码xxxx 所以,我不明白我应该在哪里输入这个代码?它将如何重定向到我的应用程序 任何帮助都将不胜感激。为其联系人导入程序提供了一个iOS小部件。从iOS设备访问以了解其工作原理Ios 在iphone中获取yahoo联系人,ios,yahoo-api,Ios,Yahoo Api,我下面的链接:用于检索雅虎联系人 在提供所有凭据(即密钥、消费者密钥、应用程序id)后,它将进入浏览器进行登录。但登录后,它会显示以下消息: 完成雅虎的分享!带有xxxx的信息,在xxxx中输入代码xxxx 所以,我不明白我应该在哪里输入这个代码?它将如何重定向到我的应用程序 任何帮助都将不胜感激。为其联系人导入程序提供了一个iOS小部件。从iOS设备访问以了解其工作原理 我在CloudSpine工作,如果您有任何问题,请告诉我。您需要指定回拨url。默认情况下,它是“oob”,并将为您提供验证
我在CloudSpine工作,如果您有任何问题,请告诉我。您需要指定回拨url。默认情况下,它是“oob”,并将为您提供验证程序代码。如果您展示自己的web视图,并通过webview代理监控验证程序代码,则效果会更好。这是你怎么做的
YOSSession *yahooSession; //instance variable
- (IBAction)yahooButtonAction:(UIButton *)sender {
yahooSession = [YOSSession sessionWithConsumerKey:YAHOO_CONSUMER_KEY
andConsumerSecret:YAHOO_CONSUMER_SECRET
andApplicationId:YAHOO_APP_ID];
// try to resume a user session if one exists
BOOL hasSession = [yahooSession resumeSession];
if(hasSession == FALSE) {
[self fetchSession];
}else{
[self sendRequests];
}
}
-(void)fetchSession{
// create a new YOSAuthRequest used to fetch OAuth tokens.
YOSAuthRequest *tokenAuthRequest = [YOSAuthRequest requestWithSession:yahooSession];
// fetch a new request token from oauth.
YOSRequestToken *newRequestToken = [tokenAuthRequest fetchRequestTokenWithCallbackUrl:@"http://localhost"];
// if it looks like we have a valid request token
if(newRequestToken && newRequestToken.key && newRequestToken.secret) {
// store the request token for later use
[yahooSession setRequestToken:newRequestToken];
[yahooSession saveSession];
// create an authorization URL for the request token
NSURL *authorizationUrl = [tokenAuthRequest authUrlForRequestToken:yahooSession.requestToken];
[self presentWebViewForYahooWithAuthURL:authorizationUrl];
//present it in webview
} else {
// NSLog(@"error fetching request token. check your consumer key and secret.");
}
}
-(void) presentWebViewForYahooWithAuthURL:(NSURL *)url{
_yahooWebView = [[UIWebView alloc] initWithFrame:self.view.frame];
_yahooWebView.delegate=self; //so that we can observe the url for verifier
[_yahooWebView loadRequest:[NSURLRequest requestWithURL:url]];
[self.view addSubview:_yahooWebView];
}
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType{
NSString *requestString = request.URL.absoluteString;
if ([requestString rangeOfString:@"http://localhost"].length>0) {
NSRange verifierRange = [requestString rangeOfString:@"oauth_verifier="];
if (verifierRange.length>0) {
verifierRange.location =verifierRange.location+verifierRange.length;
verifierRange.length = requestString.length-verifierRange.location;
NSLog(@"Verifier => %@", [requestString substringWithRange:verifierRange]);
yahooSession.verifier=[requestString substringWithRange:verifierRange];
[self sendRequests];
}
return NO;
}
else{
return YES;
}
}
谢谢@Jay,我知道你的应用程序可以正常工作,但是你是如何完成这个额外的窗口的,在幕后发生了什么?嗨@AdityaSinha,你成功地与雅虎合作了吗。我想获取yahoo用户联系人。这是第一次应用程序崩溃。当我下次尝试时。该应用程序正在运行,雅虎联系人也被抓取。但我想找出雅虎sdk的问题所在。如果可能,请提供完整的代码。我对
ApplicationId
参数也感到困惑。初始化YOSSession
时,应用程序id的值是多少。另外,请提供回调URL的相关知识。我理解回拨url用于应用程序重定向。这就是我们要写的。plist。类似于myApp://但当我们在YDN中创建新应用时,这是一个请求回调url(如facebook),并且不接受任何不是以http或https开头的字符串。@ChetanPrajapati我也有同样的问题,我被困于此。你找到解决办法了吗?请建议meI跳过此功能。