Yahoo authenticate & fetch profile details iOS

后端 未结 4 1228
别跟我提以往
别跟我提以往 2021-02-19 06:38

I\'ve listed here Yahoo Integration steps which I\'ve followed.

  • Step 1. I went to http://developer.yahoo.com/social/sdk/objectivec/
  • Step
4条回答
  •  感情败类
    2021-02-19 06:40

    Here is the solution.

    NOTE: You would be needing an intermediate server for that.

    • Step 01. Download PHP yahoo framework http://github.com/yahoo/yos-social-php
    • Step 02. Start WAMP/XAMPP server.
    • Step 03. Obtain URL
      • example - http://10.0.0.76/iOS/yos-social-php-master/sample/sampleapp.php
    • Step 04. Get back to XCode project.
    • Step 05. Open XIB, Put a button for Yahoo & connect IBAction method.
    • Step 06. In IBAction method, navigate to obtained URL from iOS App to URL. See Code Block 1
    • Step 07. Add method in AppDelegate.m for handling redirection from Server to your mobile App. See Code Block 2
    • Step 08. Make sure your app is capable handling Redirection. Open your project-info.plist as source-code & make sure you have valid URL types, URL identifier & URL Schemes. as indicated in Code Block 3
    • Step 09. Now your mobile app is ready for redirection from server.
    • Step 10. Open yourLocalServer/iOS/yos-social-php-master/sample/sampleapp.php file. (https://github.com/yahoo/yos-social-php/blob/master/sample/sampleapp.php)
    • Step 11. Comment code from 97 to 106.
    • Step 12. Put code as indicated in Code Block 4
    • Step 13. Run your project, Click on button from iOS App.
    • Step 14. App will navigate to your site-page. Site page will do the authentication & get the profile details.
    • Step 15. As soon as authentication is done, site-page will redirect back to your-mobile-app with details like - Gender, Full name, date of birth, guid, profile picture url etc.

    Summary

    Mobile App navigates to Server -> Server manages authentication via OAuth-php. Once authenticated Server retrieves profile details & server indicates safari to navigate back to - your-mobile-App. Your-mobile-app gets all details in Code Block

    Code Block 1

    - (IBAction)connectYahoo:(id)sender {
          [[UIApplication sharedApplication] 
               openURL:[NSURL URLWithString:
               @"http://yourLocalServer/iOS/yos-social-php-master/sample/sampleapp.php"
          ]];
    }
    

    Code Block 2

    - (BOOL)application:(UIApplication *)application
            openURL:(NSURL *)url
       sourceApplication:(NSString *)sourceApplication
         annotation:(id)annotation {
    
        if([[url scheme] isEqualToString:@"com.yourcompany.app.fsq"]) {
            return [self.obj_LoginHomeVCtr.foursquare handleOpenURL:url];
        } else if([[url scheme] isEqualToString:@"com.yourcompany.app.googleplus"]){
            return [GPPURLHandler handleURL:url
                      sourceApplication:sourceApplication
                             annotation:annotation];
    
        }else if([[url scheme] isEqualToString:@"fb188315544652080"]){
            return [FBAppCall handleOpenURL:url
                      sourceApplication:sourceApplication
                        fallbackHandler:^(FBAppCall *call) {
                            NSLog(@"In fallback handler");
                        }];
        } else if ([[url scheme] isEqualToString:@"com.yourcompany.app.yahoo"]){
            STLog(@"URL is %@",url);
            return YES;
        }
        return YES;
    }
    

    Code block 3

    CFBundleURLTypes
    
        
            CFBundleTypeRole
            Editor
            CFBundleURLName
            com.yourcompany.app.yahoo
            CFBundleURLSchemes
            
                com.yourcompany.app.yahoo
            
        
    
    

    Code block 4

      else if($hasSession && $profile) {
          $string = "com.yourcompany.app.yahoo://response?birthdate=" . $profile->birthdate . "&familyName=" . $profile->familyName. " " . $profile->givenName . "&gender=" . $profile->gender . "&guid=" . $profile->guid . "&image=" . $profile->image->imageUrl;
          echo '';
      }
    ?>
    

提交回复
热议问题