Retrieving a Phone Number from the Facebook Account Kit

The account documentation states that if you started a login session using AccountKitActivity.ResponseType.TOKEN, you can access the account set identifier, phone number, and email of the current account by calling getCurrentAccount ().

Is it possible to get the user's phone number if you started with AccountKitActivity.ResponseType.CODE in the same way as Saavn did?

+4
source share
4 answers

Yes, it is possible if you use LoginType.PHONE in your configuration.

    AccountKit.getCurrentAccount(new AccountKitCallback<Account>() {
        @Override
        public void onSuccess(final Account account) {
            String accountKitId = account.getId();
            PhoneNumber phoneNumber = account.getPhoneNumber();
            String phoneNumberString = phoneNumber.toString();
        }

        @Override
        public void onError(final AccountKitError error) {
            // Handle Error
        }
    });

: phoneNumberString; account.getEmail() null, LoginType.PHONE .
, LoginType.EMAIL .

+8

CODE TOKEN - . Graph api auth, , , API.

, / .

{  
   "id":"12345",
   "phone":{  
      "number":"+15551234567"
      "country_prefix": "1",
      "national_number": "5551234567"
   }
}
+3

access code/token...

server client access token mobile number and country code FB AccountKit API - https://graph.accountkit.com/v1.1/me/?access_token=xxxxxxxxxxxx. xxxxxxxxxx - access token.

auth code/token ...

access code access token server side ( App Secret) API - https://graph.accountkit.com/v1.1/access_token?grant_type=authorization_code&code=xxxxxxxxxx&access_token=AA|yyyyyyyyyy|zzzzzzzzzz. xxxxxxxxxx, yyyyyyyyyy zzzzzzzzzz - auth code, app id app secret . access token, mobile number API.

.

+1

, , :

    let accountKit = AKFAccountKit(responseType: AKFResponseType.accessToken)
    accountKit.requestAccount { (account, error) in
     if(error != nil){
        //error while fetching information
      }else{
        print("Account ID  \(account?.accountID)")
        if let email = account?.emailAddress,email.characters.count > 0{
             print("Email\(email)")
        }else if let phoneNum = account?.phoneNumber{
             print("Phone Number\(phoneNum.stringRepresentation())")
        }
      }
    }
+1

All Articles