เวอร์ชันของ 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{ภาษา}

ช่อง

ชื่อ คำอธิบาย ประเภท

id

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
}];

สิทธิ์การอนุญาต

  • ต้องระบุโทเค็นการเข้าถึงแอพเพื่อเพิ่มสตริงการแปลใหม่สำหรับแอพนั้น

ช่อง

ชื่อ คำอธิบาย ประเภท

เวคเตอร์

เวคเตอร์

เวคเตอร์

การตอบกลับ

หากสำเร็จ คุณจะได้รับการตอบกลับธรรมดาที่ระบุจำนวนสตริงที่เพิ่มเข้ามา แต่หากไม่สำเร็จ ระบบจะส่งข้อความแสดงข้อผิดพลาดกลับมา

การลบ

คุณสามารถลบสตริงการแปลโดยใช้การดำเนินการนี้ได้

<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[]

การตอบกลับ

หากสำเร็จ คุณจะได้รับการตอบกลับธรรมดาที่ระบุจำนวนสตริงที่ลบ แต่หากไม่สำเร็จ ระบบจะส่งข้อความแสดงข้อผิดพลาดกลับมา