Graph 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

測試用戶的朋友:您可以使用此關係連線,來將兩位測試用戶加為朋友。