3

私はこのリンクをたどっています: https://github.com/yahoo/yos-social-objc yahoo の連絡先を取得するため。

すべての資格情報 (つまり、秘密鍵、コンシューマー キー、アプリ ID) を提供した後、ログインのためにブラウザーに移動します。しかし、ログインすると、次のメッセージが表示されます。

yahoo!の共有を完了するには info with xxxx、コード xxxx を xxxx に入力

それで、私はこのコードをどこに入力すればよいのですか?そして、どのように私のアプリケーションにリダイレクトしますか。

どんな助けでも大歓迎です。

4

2 に答える 2

0

CloudSpongeには、連絡先インポーター用の iOS ウィジェットがあります。iOS デバイスからテスト ドライブ ページにアクセスして、その動作を確認してください。

私は CloudSponge で働いています。質問があればお知らせください。

于 2012-10-12T06:45:08.780 に答える
0

コールバック URL を指定する必要があります。デフォルトでは「oob」で、検証コードを提供します。独自の Web ビューを提示し、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;
    }
}
于 2014-01-03T12:29:18.617 に答える