我正在关注此链接:https://github.com/yahoo/yos-social-objc以检索雅虎联系人。获取iphone中的雅虎联系人
提供所有凭据(即密钥,消费者密钥,应用程序ID)后,它将浏览器登录。但登录后,它显示此消息:
要完成雅虎共享!信息与xxxx,输入代码xxxx到xxxx
所以,我没有得到,我应该输入此代码?它将如何重定向到我的应用程序。
任何帮助将不胜感激。
我正在关注此链接:https://github.com/yahoo/yos-social-objc以检索雅虎联系人。获取iphone中的雅虎联系人
提供所有凭据(即密钥,消费者密钥,应用程序ID)后,它将浏览器登录。但登录后,它显示此消息:
要完成雅虎共享!信息与xxxx,输入代码xxxx到xxxx
所以,我没有得到,我应该输入此代码?它将如何重定向到我的应用程序。
任何帮助将不胜感激。
CloudSponge为其联系进口商提供了一个iOS部件。通过iOS设备访问our test drive page,了解它是如何工作的。
我为CloudSponge工作,如果您有任何问题,请让我知道。
谢谢@Jay,我发现你的应用程序可以工作,但你怎么做额外的窗口,那里幕后发生了什么? – Kamilski81
您需要指定回调网址。默认情况下它是“oob”,并会给你验证码。如果您通过webview代理呈现自己的Web视图并监视验证者代码,那将会更好。这是你如何做到的。
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;
}
}
嗨@AdityaSinha,你有没有成功地与雅虎合作。我想获取雅虎用户的联系人。第一次应用程序崩溃。当我下次尝试时。该应用程序正在工作,雅虎联系人也提取。但我想找出与雅虎sdk有什么问题。如果可能,请提供完整的代码。 –
我也困惑'ApplicationId'参数。初始化'YOSSession'时应用程序id的价值是什么。 –
也请提供callbackurl的知识。我了解,回调网址用于应用重定向。那就是我们将在.plist中写入。像myApp://但是当我们在YDN中创建新应用程序时,这是要求回调URL(如Facebook),并且不接受任何不是从http或https开始的字符串。 –
你知道吗? – Kamilski81