MessengerExtensions.getUserID()

Messenger Extensions SDK

This method is a part of the Messenger Extensions SDK. For information on including the SDK in your site, see Add Messenger Extensions SDK.

getUserID() is Deprecated - Use getContext()


Bots that transmit the user ID for the purpose of performing an action on the server and require the ability to verify it should instead use the MessengerExtensions.getContext(). getUserID() is not supported in the webview for the Messenger web client.

The getUserID() method of the Messenger Extensions SDK retrieves the app-scoped ID (if available) and page-scoped ID of the person that opened the webview.

Contents

Method

MessengerExtensions.getUserID(success, error)

Example

MessengerExtensions.getUserID(function success(user_ids) {
  // User ID was successfully obtained. 
  let psid = user_ids.psid;

}, function error(err, errorMessage) {      
  // Error handling code
});

Parameters

Parameter Type Description

success

Function

Success callback function. Receives the user_id object as an argument.

error

Function

Error callback function. Called if Messenger was unable to retrieve the user ID.

user_ids Object

The user_ids object is passed to the success callback.

{
  "asid": "<APP_SCOPED_ID>",
  "psid": "<PAGE_SCOPED_ID>"
}

Properties

Property Type Description

asid

String

The app-scoped ID of the person that opened the webview. If there is no ASID, value will be null.

psid

String

The PSID of the person that opened the webview.