图谱 API 版

/{app-id}/translations

此应用中使用我们的翻译工具翻译的字符串。

读取

GET /v25.0/{app-id}/translations?locale=fr_FR 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(
    '/{app-id}/translations?locale=fr_FR',
    '{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("locale", "fr_FR");
/* make the API call */
new GraphRequest(
    AccessToken.getCurrentAccessToken(),
    "/{app-id}/translations",
    params,
    HttpMethod.GET,
    new GraphRequest.Callback() {
        public void onCompleted(GraphResponse response) {
            /* handle the result */
        }
    }
).executeAsync();
NSDictionary *params = @{
  @"locale": @"fr_FR",
};
/* make the API call */
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
                               initWithGraphPath:@"/{app-id}/translations"
                                      parameters:params
                                      HTTPMethod:@"GET"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection,
                                      id result,
                                      NSError *error) {
    // Handle the result
}];

权限

  • 需要应用访问口令,才能为该应用返回译文。

修饰符

名称 描述 类型

locale

指定要请求获取的语言。这是读取此连线的一个必要参数。

enum{locale}

字段

名称 描述 类型

id

每个字符串的唯一编号。

string

translation

翻译后的字符串。

string

approval_status

字符串的审核状态。

enum{auto-approved, approved, unapproved}

native_string

被翻译的原始字符串。

string

description

提供的字符串描述。

string

发布

您可以使用此连线为应用指定要翻译的新字符串:

POST /v25.0/{app-id}/translations HTTP/1.1
Host: graph.facebook.com

native_strings=%5B%7B%22text%22%3A%22Test+String%22%2C+%22description%22%3A+%22This+is+a+test+string+for+an+app.%22%7D%5D
/* PHP SDK v5.0.0 */
/* make the API call */
try {
  // Returns a `Facebook\FacebookResponse` object
  $response = $fb->post(
    '/{app-id}/translations',
    array (
      'native_strings' => '[{"text":"Test String", "description": "This is a test string for an app."}]',
    ),
    '{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("native_strings", "[{\"text\":\"Test String\", \"description\": \"This is a test string for an app.\"}]");
/* make the API call */
new GraphRequest(
    AccessToken.getCurrentAccessToken(),
    "/{app-id}/translations",
    params,
    HttpMethod.POST,
    new GraphRequest.Callback() {
        public void onCompleted(GraphResponse response) {
            /* handle the result */
        }
    }
).executeAsync();
NSDictionary *params = @{
  @"native_strings": @"[{\"text\":\"Test String\", \"description\": \"This is a test string for an app.\"}]",
};
/* make the API call */
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
                               initWithGraphPath:@"/{app-id}/translations"
                                      parameters:params
                                      HTTPMethod:@"POST"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection,
                                      id result,
                                      NSError *error) {
    // Handle the result
}];

权限

  • 需要应用访问口令,才能为该应用添加新的译文字符串。

字段

名称 描述 类型

Vector

向量

Vector

响应

如果成功,您将收到有关所添加字符串数量的普通响应;否则,将收到错误消息。

删除

您可以使用以下操作删除译文字符串:

<code-tabs-path language="phpsdk,iossdk,androidsdk,http" method="DELETE" param='{"native_hashes":"['hash1', 'hash2']"}' path="/{app-id}/translations" rendering_context="1" />

权限

  • 需要应用访问口令,才能从该应用删除译文字符串。

字段

名称 描述 类型

native_hashes

一个包含每个译文字符串哈希值的数组。哈希值是每个字符串的唯一标识符,可使用 translation FQL 表格进行检索。

string[]

响应

如果成功,您将收到有关所删除字符串数量的普通响应;否则,将收到错误消息。