通过android和iPhone应用程序集成雅虎、谷歌和openid



我正在为iPhone和android设计一个应用程序,其中我必须集成facebook、twitter、雅虎、gmail、openId。我已经集成了脸书和推特,但雅虎、gmail和openId该怎么办?如何通过应用程序登录并获取用户信息?

请告诉我实现这一点的方法。任何教程都可能有所帮助。

谢谢。

要集成gmail,这个url可以帮助您
谷歌文档
关于将gmail与iphone集成的介绍
与iphone集成的示例
Api用于集成博客、谷歌分析等
对于雅虎,你可以使用这个

    String YAHOO_RESOURCE_URL = "http://social.yahooapis.com/v1/me/guid/profile?fomat=xml";
    String CALLBACK_URL = "oauth://testApp";
    String YAHOO_REQUEST_TOKEN_URL = "https://api.login.yahoo.com/oauth/v2/get_request_token";
    String YAHOO_ACCESS_TOKEN_URL = "https://api.login.yahoo.com/oauth/v2/get_token";
    String YAHOO_AUTHORIZE_URL = "https://api.login.yahoo.com/oauth/v2/request_auth";
    // Oauth consumer and provider.
    CommonsHttpOAuthConsumer consumer = new CommonsHttpOAuthConsumer(Constants.YAHOO_CONSUMER_KEY, Constants.YAHOO_CONSUMER_SERECT_KEY);
    OAuthProvider provider = new CommonsHttpOAuthProvider(YAHOO_REQUEST_TOKEN_URL , YAHOO_ACCESS_TOKEN_URL, YAHOO_AUTHORIZE_URL);
    provider.setOAuth10a(true);
    // First retrive request token.
    String authUrl = provider.retrieveRequestToken(consumer, CALLBACK_URL);
    String yahooToken = consumer.getToken();
    String yahooTokenSecret = consumer.getTokenSecret();
    Open the authUrl in android web browser, this will launch login page, then after login will ask for permissions, accepting the permissions will return in your app using callback url.
    Now,
    In onResume
    Uri uri = this.getIntent().getData();
    if (uri != null && uri.toString().startsWith(CALLBACK_URL)) {
    String oauthToken = uri.getQueryParameter(oauth.signpost.OAuth.OAUTH_TOKEN);
    String oauthVerifier = uri.getQueryParameter(oauth.signpost.OAuth.OAUTH_VERIFIER);
    consumer = new CommonsHttpOAuthConsumer(Constants.YAHOO_CONSUMER_KEY, Constants.YAHOO_CONSUMER_SERECT_KEY);
    consumer.setTokenWithSecret(yahooToken, yahooTokenSecret);
    provider = new CommonsHttpOAuthProvider(YAHOO_REQUEST_TOKEN_URL, YAHOO_ACCESS_TOKEN_URL, YAHOO_AUTHORIZE_URL);
    provider.setOAuth10a(true);
    // Now retrive access token
    provider.retrieveAccessToken(consumer, oauthVerifier);
    String token = consumer.getToken();
    String tokenSecret = consumer.getTokenSecret();
    consumer.setTokenWithSecret(token, tokenSecret);
    //  Get the GUID from this.
    DefaultHttpClient httpClient = new DefaultHttpClient();
    HttpGet request = new HttpGet("http://social.yahooapis.com/v1/me/guid?format=json");
    consumer.sign(request);
    HttpResponse response = httpClient.execute(request);

分析响应以获取GUID。

    // Now use the GUID to get profile info.
    DefaultHttpClient httpClient = new DefaultHttpClient();
    String strUrl = "http://social.yahooapis.com/v1/user/"+ strGUID +"/profile?format=json";
    HttpGet request = new HttpGet(strUrl);
    consumer.sign(request);
    HttpResponse response = httpClient.execute(request);

解析响应并njoy:)

相关内容

  • 没有找到相关文章

最新更新