Getting username and profile picture from Facebook iOS 7

Le'Kirdok

I have read a lot of tutorials about getting information from Facebook, but I have failed so far. I just want to get username and profile picture from Facebook.

- (IBAction)login:(id)sender {

   [FBSession openActiveSessionWithReadPermissions:@[@"email",@"user_location",@"user_birthday",@"user_hometown"]
                                   allowLoginUI:YES
                              completionHandler:^(FBSession *session, FBSessionState state, NSError *error) {

   switch (state) {
      case FBSessionStateOpen:
         [[FBRequest requestForMe] startWithCompletionHandler:^(FBRequestConnection *connection, NSDictionary<FBGraphUser> *user, NSError *error) {
            if (error) {
               NSLog(@"error:%@",error);
            } else {
               // retrive user's details at here as shown below
               NSLog(@"FB user first name:%@",user.first_name);
               NSLog(@"FB user last name:%@",user.last_name);
               NSLog(@"FB user birthday:%@",user.birthday);
               NSLog(@"FB user location:%@",user.location);
               NSLog(@"FB user username:%@",user.username);
               NSLog(@"FB user gender:%@",[user objectForKey:@"gender"]);
               NSLog(@"email id:%@",[user objectForKey:@"email"]);
               NSLog(@"location:%@", [NSString stringWithFormat:@"Location: %@\n\n",
                                                                         user.location[@"name"]]);

             }
        }];
        break;
        case FBSessionStateClosed:
        case FBSessionStateClosedLoginFailed:
           [FBSession.activeSession closeAndClearTokenInformation];
        break;
        default:
        break;
       }

   } ];


 }

I used this code for get information, but I cannot get the any information. Can you help me about it? or Can you prefer a tutorial to read it? I have read tutorials on developer.facebook.com.

Thank you for your interest.

Guilherme

This is the simplest way I've found to get the user's profile picture.

[[FBRequest requestForMe] startWithCompletionHandler:^(FBRequestConnection *connection, NSDictionary<FBGraphUser> *FBuser, NSError *error) {
    if (error) {
      // Handle error
    }

    else {
      NSString *userName = [FBuser name];
      NSString *userImageURL = [NSString stringWithFormat:@"https://graph.facebook.com/%@/picture?type=large", [FBuser objectID]];
    }
  }];

Other query parameters that can be used are:

  • type: small, normal, large, square
  • width: < value >
  • height: < value >
    • Use both width and height to get a cropped, aspect fill image

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Getting Facebook Profile Picture in Android

From Dev

iOS7 Access user Facebook Profile Picture

From Dev

Getting large Facebook profile picture with url

From Dev

Error while getting facebook profile picture in Android

From Dev

Get Facebook API Profile Picture ios Swift

From Dev

get profile picture from facebook and set in imageview

From Dev

Android - Get profile cover picture from Facebook

From Dev

how to fetch profile picture from facebook

From Dev

Getting user's facebook profile picture using picasso

From Dev

Not getting user's Facebook Profile picture using SDK

From Dev

Getting facebook public profile of a person in ios app

From Dev

How to fetch profile picture from Google + in iOS?

From Dev

Return Facebook profile picture

From Dev

No username returned in facebook profile

From Dev

No username returned in facebook profile

From Dev

Facebook iOS SDK and swift: how get user's profile picture

From Dev

Get profile picture from Facebook Graph-API

From Dev

Get profile picture from Facebook Graph-API

From Dev

Copy Facebook profile picture from Graph API URL

From Dev

Getting gmail public profile picture from gmail address

From Dev

Detecting profile picture change on Facebook

From Dev

Retrieving URL of Facebook profile picture

From Dev

Display User Profile Picture from Salesforce in iOS App

From Dev

Display User Profile Picture from Salesforce in iOS App

From Dev

Getting email using ACAccount for Facebook iOS 7

From Dev

How to set profile picture obtained from facebook login to user profile in another activity

From Dev

Getting profile picture with swift through Facebook Graph API return "unsupported URL"

From Dev

I am trying to download facebook profile picture using java.But getting error

From Dev

Use Facebook profile picture as you profile picture Swift

Related Related

  1. 1

    Getting Facebook Profile Picture in Android

  2. 2

    iOS7 Access user Facebook Profile Picture

  3. 3

    Getting large Facebook profile picture with url

  4. 4

    Error while getting facebook profile picture in Android

  5. 5

    Get Facebook API Profile Picture ios Swift

  6. 6

    get profile picture from facebook and set in imageview

  7. 7

    Android - Get profile cover picture from Facebook

  8. 8

    how to fetch profile picture from facebook

  9. 9

    Getting user's facebook profile picture using picasso

  10. 10

    Not getting user's Facebook Profile picture using SDK

  11. 11

    Getting facebook public profile of a person in ios app

  12. 12

    How to fetch profile picture from Google + in iOS?

  13. 13

    Return Facebook profile picture

  14. 14

    No username returned in facebook profile

  15. 15

    No username returned in facebook profile

  16. 16

    Facebook iOS SDK and swift: how get user's profile picture

  17. 17

    Get profile picture from Facebook Graph-API

  18. 18

    Get profile picture from Facebook Graph-API

  19. 19

    Copy Facebook profile picture from Graph API URL

  20. 20

    Getting gmail public profile picture from gmail address

  21. 21

    Detecting profile picture change on Facebook

  22. 22

    Retrieving URL of Facebook profile picture

  23. 23

    Display User Profile Picture from Salesforce in iOS App

  24. 24

    Display User Profile Picture from Salesforce in iOS App

  25. 25

    Getting email using ACAccount for Facebook iOS 7

  26. 26

    How to set profile picture obtained from facebook login to user profile in another activity

  27. 27

    Getting profile picture with swift through Facebook Graph API return "unsupported URL"

  28. 28

    I am trying to download facebook profile picture using java.But getting error

  29. 29

    Use Facebook profile picture as you profile picture Swift

HotTag

Archive