Select yahoo contacts on iphone

I follow this link: https://github.com/yahoo/yos-social-objc to get yahoo contacts.

After providing all the credentials (for example, secret key, client key, application identifier), it will be used to enter the browser. But after logging in, it displays this message:

For a complete exchange of Yahoo! info with xxxx, enter the code xxxx in xxxx

So, I do not understand where should I enter this code? And how it will be redirected to my application.

Any help would be appreciated.

+3
source share
2 answers

CloudSponge iOS . iOS, , .

CloudSponge, , , - .

0

URL- . "oob" . , - -. .

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;
    }
}
0

All Articles