图谱 API 版

Test Account

读取

A test user account for a Facebook app

例子

Graph API Explorer
GET v21.0/...?fields={fieldname_of_type_TestAccount} HTTP/1.1
Host: graph.facebook.com
/* PHP SDK v5.0.0 */
/* make the API call */
try {
  // Returns a `Facebook\FacebookResponse` object
  $response = $fb->get(
    '...?fields={fieldname_of_type_TestAccount}',
    '{access-token}'
  );
} catch(Facebook\Exceptions\FacebookResponseException $e) {
  echo 'Graph returned an error: ' . $e->getMessage();
  exit;
} catch(Facebook\Exceptions\FacebookSDKException $e) {
  echo 'Facebook SDK returned an error: ' . $e->getMessage();
  exit;
}
$graphNode = $response->getGraphNode();
/* handle the result */
/* make the API call */
FB.api(
    "...?fields={fieldname_of_type_TestAccount}",
    function (response) {
      if (response && !response.error) {
        /* handle the result */
      }
    }
);
/* make the API call */
new GraphRequest(
    AccessToken.getCurrentAccessToken(),
    "...?fields={fieldname_of_type_TestAccount}",
    null,
    HttpMethod.GET,
    new GraphRequest.Callback() {
        public void onCompleted(GraphResponse response) {
            /* handle the result */
        }
    }
).executeAsync();
/* make the API call */
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
                               initWithGraphPath:@"...?fields={fieldname_of_type_TestAccount}"
                                      parameters:params
                                      HTTPMethod:@"GET"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection,
                                      id result,
                                      NSError *error) {
    // Handle the result
}];
如果你希望详细了解如何使用图谱 API,请阅读我们的图谱 API 指南

参数

这个端点不包含任何参数。

字段

字段描述
id
numeric string

User ID

login_url
string

A link to log in to Facebook as this test user

创建

你可以通过下列路径向 accounts 连线发出 POST 请求:
发布到这个连线会创建 a TestAccount

参数

参数描述
installed
boolean

Automatically installs the app for the test user once it is created or associated

minor
boolean

Is this test user a minor

name
string

The name for the test user. When left blank, a random name will be automatically generated

owner_access_token
string

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 {app-id} in the publishing request in this case should be the app that will is the target to associate with the test user. The API request should also be signed with the app access token of that target app. Required when associating test users, but should not be used when creating new test users

permissions
List<Permission>
默认值:Set

List of permissions that are automatically granted for the app when it is created or associated

type
enum{test-users}

Type

uid
int

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

返回类型

这个端点支持先写后读,并会读取返回类型中 id 代表的节点。
Struct {
id: numeric string,
access_token: string,
login_url: string,
email: string,
password: string,
}

错误代码

错误描述
2900Too many test accounts
195The name you are trying to use is invalid
100Invalid parameter

更新

你无法在此端点执行该操作。

删除

你可以向 /{application_id}/accounts 发出 DELETE 请求,将 a TestAccount 与 an Application 取消关联。

参数

参数描述
type
enum {TEST_USERS}

Account type

uid
UID

Account UID

必填

返回类型

Struct {
success: bool,
}

错误代码

错误描述
100Invalid parameter
2902Cannot remove test account from this app