Graph API Reference /{app-id}/accounts/test-users
The test users associated with this app.
Related Guides
Reading
GET /v2.9/{app-id}/accounts/test-users HTTP/1.1
Host: graph.facebook.com/* PHP SDK v5.0.0 */
/* make the API call */
$request = new FacebookRequest(
$session,
'GET',
'/{app-id}/accounts/test-users'
);
$response = $request->execute();
$graphObject = $response->getGraphObject();
/* handle the result *//* make the API call */
new GraphRequest(
AccessToken.getCurrentAccessToken(),
"/{app-id}/accounts/test-users",
null,
HttpMethod.GET,
new GraphRequest.Callback() {
public void onCompleted(GraphResponse response) {
/* handle the result */
}
}
).executeAsync();// For more complex open graph stories, use `FBSDKShareAPI`
// with `FBSDKShareOpenGraphContent`
/* make the API call */
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
initWithGraphPath:@"/{app-id}/accounts/test-users"
parameters:params
HTTPMethod:@"GET"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection,
id result,
NSError *error) {
// Handle the result
}];Permissions
- An app access token for the app in the request is required.
Fields
| Name | Description | Type |
|---|---|---|
| The user ID of the test user. |
|
| The access token for the test user and this app. This field is only visible if the test user has installed the app. |
|
| This URL will allow the test user account to be logged into. The URL will expire one hour after it is generated, or after the first time it is used. |
|
Publishing
By publishing using this edge, you can create new test users and you can assosciate existing test users with new apps.
POST /v2.9/{app-id}/accounts/test-users HTTP/1.1
Host: graph.facebook.com
installed=true/* PHP SDK v5.0.0 */
/* make the API call */
$request = new FacebookRequest(
$session,
'POST',
'/{app-id}/accounts/test-users',
array (
'installed' => 'true',
)
);
$response = $request->execute();
$graphObject = $response->getGraphObject();
/* handle the result */Bundle params = new Bundle();
params.putString("installed", "true");
/* make the API call */
new GraphRequest(
AccessToken.getCurrentAccessToken(),
"/{app-id}/accounts/test-users",
params,
HttpMethod.POST,
new GraphRequest.Callback() {
public void onCompleted(GraphResponse response) {
/* handle the result */
}
}
).executeAsync();// For more complex open graph stories, use `FBSDKShareAPI`
// with `FBSDKShareOpenGraphContent`
NSDictionary *params = @{
@"installed": @"true",
};
/* make the API call */
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
initWithGraphPath:@"/{app-id}/accounts/test-users"
parameters:params
HTTPMethod:@"POST"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection,
id result,
NSError *error) {
// Handle the result
}];Permissions
- An app access token is required to create new test users for that app.
- If associating existing test users with new apps, app access tokens are required for both the app that created the test user, and the app that is being newly associated to the test user (see
owner_access_tokenfor more).
Fields
| Name | Description | Type |
|---|---|---|
| Automatically installs the app for the test user once it is created or associated. |
|
| List of permissions that are automatically granted for the app when it is created or associated. |
|
| The name for the test user. When left blank, a random name will be automatically generated. |
|
| When associating existing test users with other apps, this is the app access token of any app that is already associated with the test user. The |
|
| ID of an existing test user to associate with another app. Required when associating test users, but should not be used when creating new test users. |
|
Response
When a test user is successfully created or associated the following will be returned, otherwise an error message will be shown:
| Name | Description | Type |
|---|---|---|
| The new test user ID |
|
| The access token belonging to the test user. Only included when the test user has |
|
| This URL will allow the test user account to be logged into. The URL will expire one hour after it is generated, or after the first time it is used. |
|
| The test user's email address. |
|
| The test user's password. |
|
Deleting
You can't delete a test user using this edge, however you can delete a test user using the /{test-user-id} node.
When deleting using this edge, you can disassociate a test user from an app:
DELETE /v2.9/{app-id}/accounts/test-users HTTP/1.1
Host: graph.facebook.com
uid=12345678/* PHP SDK v5.0.0 */
/* make the API call */
$request = new FacebookRequest(
$session,
'DELETE',
'/{app-id}/accounts/test-users',
array (
'uid' => '12345678',
)
);
$response = $request->execute();
$graphObject = $response->getGraphObject();
/* handle the result */Bundle params = new Bundle();
params.putString("uid", "12345678");
/* make the API call */
new GraphRequest(
AccessToken.getCurrentAccessToken(),
"/{app-id}/accounts/test-users",
params,
HttpMethod.DELETE,
new GraphRequest.Callback() {
public void onCompleted(GraphResponse response) {
/* handle the result */
}
}
).executeAsync();// For more complex open graph stories, use `FBSDKShareAPI`
// with `FBSDKShareOpenGraphContent`
NSDictionary *params = @{
@"uid": @"12345678",
};
/* make the API call */
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
initWithGraphPath:@"/{app-id}/accounts/test-users"
parameters:params
HTTPMethod:@"DELETE"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection,
id result,
NSError *error) {
// Handle the result
}];Permissions
- The associated app access token is required to disassociate a test user.
- A test user must still be associated with any single app after this operation, otherwise an error message (
2902) will be shown.
Fields
| Name | Description | Type |
|---|---|---|
| The ID of the test user to be disassociated from the app. |
|
Response
If successful:
{
"success": true
}
Otherwise a relevant error message will be returned.
Updating
You can't update a test user using this edge, however you can update a test user using the /{test-user-id} node.