圖形 API 版本

測試用戶 /{test-user-id}

與 Facebook 應用程式相關聯的測試用戶。測試用戶是透過 /{app-id}/accounts/test-users 關係連線或在應用程式主控板中建立或產生關聯。

相關指南

讀取

此節點上的讀取操作權限和欄位與一般 /{user-id} 節點的權限和欄位相同

發佈與更新

您可以發佈至此節點來更新測試用戶的密碼或名稱。

POST /v19.0/{test-user-id} HTTP/1.1
Host: graph.facebook.com

password=newpassword&name=Newname+Smith
/* PHP SDK v5.0.0 */
/* make the API call */
try {
  // Returns a `Facebook\FacebookResponse` object
  $response = $fb->post(
    '/{test-user-id}',
    array (
      'password' => 'newpassword',
      'name' => 'Newname Smith',
    ),
    '{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 */
Bundle params = new Bundle();
params.putString("password", "newpassword");
params.putString("name", "Newname Smith");
/* make the API call */
new GraphRequest(
    AccessToken.getCurrentAccessToken(),
    "/{test-user-id}",
    params,
    HttpMethod.POST,
    new GraphRequest.Callback() {
        public void onCompleted(GraphResponse response) {
            /* handle the result */
        }
    }
).executeAsync();
NSDictionary *params = @{
  @"password": @"newpassword",
  @"name": @"Newname Smith",
};
/* make the API call */
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
                               initWithGraphPath:@"/{test-user-id}"
                                      parameters:params
                                      HTTPMethod:@"POST"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection,
                                      id result,
                                      NSError *error) {
    // Handle the result
}];

權限

  • 必須具備應用程式存取權杖,才能為與該應用程式相關聯的任何測試用戶更新這些欄位。

欄位

名稱 說明 類型

name

測試用戶的新名稱。

string

password

測試用戶的新密碼。

string

回應

更新成功時為 true,否則會出現錯誤訊息。

刪除

若要刪除測試用戶,請在此節點上進行刪除作業。

DELETE /v19.0/{test-user-id} HTTP/1.1
Host: graph.facebook.com
/* PHP SDK v5.0.0 */
/* make the API call */
try {
  // Returns a `Facebook\FacebookResponse` object
  $response = $fb->delete(
    '/{test-user-id}',
    array (),
    '{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 */
new GraphRequest(
    AccessToken.getCurrentAccessToken(),
    "/{test-user-id}",
    null,
    HttpMethod.DELETE,
    new GraphRequest.Callback() {
        public void onCompleted(GraphResponse response) {
            /* handle the result */
        }
    }
).executeAsync();
/* make the API call */
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
                               initWithGraphPath:@"/{test-user-id}"
                                      parameters:params
                                      HTTPMethod:@"DELETE"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection,
                                      id result,
                                      NSError *error) {
    // Handle the result
}];

權限

  • 必須使用關聯應用程式的應用程式存取權杖,或測試用戶自己的存取權杖,才能刪除該測試用戶。
  • 測試用戶只能與單一應用程式相關聯,必須與其他所有應用程式解除關聯。您可以使用 /{app-id}/accounts/test-users 關係連線來解除與測試用戶的關聯。

欄位

不需刪除任何欄位。

回應

刪除成功時為 true,否則會出現錯誤訊息。

關係連線

名稱 說明

/friends

測試用戶的朋友 - 此關係連線可用於讓兩個測試用戶成為朋友。