

Terjemahan disediakan oleh mesin penerjemah. Jika konten terjemahan yang diberikan bertentangan dengan versi bahasa Inggris aslinya, utamakan versi bahasa Inggris.

# Mendapatkan informasi tentang selebriti
<a name="get-celebrity-info-procedure"></a>

Dalam prosedur ini, Anda mendapatkan informasi selebriti dengan menggunakan Operasi API [getCelebrityInfo](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_GetCelebrityInfo.html). Selebriti diidentifikasi dengan menggunakan ID selebriti yang dikirimkan dari panggilan sebelumnya ke [RecognizeCelebrities](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_RecognizeCelebrities.html). 

## Memanggil GetCelebrityInfo
<a name="get-celebrity-info-examples"></a>



Prosedur ini memerlukan ID selebriti untuk selebriti yang diketahui oleh Amazon Rekognition. Gunakan ID selebriti yang Anda catat di [Mengenali selebriti dalam sebuah citra](celebrities-procedure-image.md). 

**Untuk mendapatkan informasi selebriti (SDK)**

1. Jika belum:

   1. Buat atau perbarui pengguna dengan `AmazonRekognitionFullAccess` dan `AmazonS3ReadOnlyAccess` izin. Untuk informasi selengkapnya, lihat [Langkah 1: Siapkan akun AWS dan buat Pengguna](setting-up.md#setting-up-iam).

   1. Instal dan konfigurasikan AWS CLI dan AWS SDKs. Untuk informasi selengkapnya, lihat [Langkah 2: Mengatur AWS CLI dan AWS SDKs](setup-awscli-sdk.md).

1. Gunakan contoh berikut ini untuk memanggil operasi `GetCelebrityInfo`.

------
#### [ Java ]

   Contoh ini menampilkan nama dan informasi tentang selebriti.

   Ganti `id` dengan salah satu selebriti yang IDs ditampilkan di[Mengenali selebriti dalam sebuah citra](celebrities-procedure-image.md).

   ```
   //Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
   //PDX-License-Identifier: MIT-0 (For details, see https://github.com/awsdocs/amazon-rekognition-developer-guide/blob/master/LICENSE-SAMPLECODE.)
   
   package aws.example.rekognition.image;
   import com.amazonaws.services.rekognition.AmazonRekognition;
   import com.amazonaws.services.rekognition.AmazonRekognitionClientBuilder;
   import com.amazonaws.services.rekognition.model.GetCelebrityInfoRequest;
   import com.amazonaws.services.rekognition.model.GetCelebrityInfoResult;
   
   
   public class CelebrityInfo {
   
      public static void main(String[] args) {
         String id = "nnnnnnnn";
   
         AmazonRekognition rekognitionClient = AmazonRekognitionClientBuilder.defaultClient();
   
         GetCelebrityInfoRequest request = new GetCelebrityInfoRequest()
            .withId(id);
   
         System.out.println("Getting information for celebrity: " + id);
   
         GetCelebrityInfoResult result=rekognitionClient.getCelebrityInfo(request);
   
         //Display celebrity information
         System.out.println("celebrity name: " + result.getName());
         System.out.println("Further information (if available):");
         for (String url: result.getUrls()){
            System.out.println(url);
         }
      }
   }
   ```

------
#### [ Java V2 ]

   Kode ini diambil dari GitHub repositori contoh SDK AWS Dokumentasi. Lihat contoh lengkapnya [di sini](https://github.com/awsdocs/aws-doc-sdk-examples/blob/master/javav2/example_code/rekognition/src/main/java/com/example/rekognition/CelebrityInfo.java).

   ```
   import software.amazon.awssdk.regions.Region;
   import software.amazon.awssdk.services.rekognition.RekognitionClient;
   import software.amazon.awssdk.services.rekognition.model.GetCelebrityInfoRequest;
   import software.amazon.awssdk.services.rekognition.model.GetCelebrityInfoResponse;
   import software.amazon.awssdk.services.rekognition.model.RekognitionException;
   
   /**
    * Before running this Java V2 code example, set up your development
    * environment, including your credentials.
    *
    * For more information, see the following documentation topic:
    *
    * https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/get-started.html
    */
   public class CelebrityInfo {
       public static void main(String[] args) {
           final String usage = """
   
                   Usage:    <id>
   
                   Where:
                      id - The id value of the celebrity. You can use the RecognizeCelebrities example to get the ID value.\s
                   """;
   
           if (args.length != 1) {
               System.out.println(usage);
               System.exit(1);
           }
   
           String id = args[0];
           Region region = Region.US_WEST_2;
           RekognitionClient rekClient = RekognitionClient.builder()
                   .region(region)
                   .build();
   
           getCelebrityInfo(rekClient, id);
           rekClient.close();
       }
   
       /**
        * Retrieves information about a celebrity identified in an image.
        *
        * @param rekClient the Amazon Rekognition client used to make the API call
        * @param id the unique identifier of the celebrity
        * @throws RekognitionException if there is an error retrieving the celebrity information
        */
       public static void getCelebrityInfo(RekognitionClient rekClient, String id) {
           try {
               GetCelebrityInfoRequest info = GetCelebrityInfoRequest.builder()
                       .id(id)
                       .build();
   
               GetCelebrityInfoResponse response = rekClient.getCelebrityInfo(info);
               System.out.println("celebrity name: " + response.name());
               System.out.println("Further information (if available):");
               for (String url : response.urls()) {
                   System.out.println(url);
               }
   
           } catch (RekognitionException e) {
               System.out.println(e.getMessage());
               System.exit(1);
           }
       }
   }
   ```

------
#### [ AWS CLI ]

    AWS CLI Perintah ini menampilkan output JSON untuk operasi `get-celebrity-info` CLI. Ganti `ID` dengan salah satu selebriti yang IDs ditampilkan di[Mengenali selebriti dalam sebuah citra](celebrities-procedure-image.md). Ganti nilai `profile-name` dengan nama profil pengembang Anda.

   ```
   aws rekognition get-celebrity-info --id celebrity-id --profile profile-name
   ```

------
#### [ Python ]

   Contoh ini menampilkan nama dan informasi tentang selebriti.

   Ganti `id` dengan salah satu selebriti yang IDs ditampilkan di[Mengenali selebriti dalam sebuah citra](celebrities-procedure-image.md). Ganti nilai `profile_name` di baris yang membuat sesi Rekognition dengan nama profil pengembang Anda.

   ```
   # Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
   # PDX-License-Identifier: MIT-0 (For details, see https://github.com/awsdocs/amazon-rekognition-developer-guide/blob/master/LICENSE-SAMPLECODE.)
   
   import boto3
   
   def get_celebrity_info(id):
   
       session = boto3.Session(profile_name='profile-name')
       client = session.client('rekognition')
   
       # Display celebrity info
       print('Getting celebrity info for celebrity: ' + id)
   
       response = client.get_celebrity_info(Id=id)
   
       print(response['Name'])
       print('Further information (if available):')
       for url in response['Urls']:
           print(url)
   
   def main():
       id = "celebrity-id"
       celebrity_info = get_celebrity_info(id)
   
   if __name__ == "__main__":
       main()
   ```

------
#### [ .NET ]

   Contoh ini menampilkan nama dan informasi tentang selebriti.

   Ganti `id` dengan salah satu selebriti yang IDs ditampilkan di[Mengenali selebriti dalam sebuah citra](celebrities-procedure-image.md).

   ```
   //Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
   //PDX-License-Identifier: MIT-0 (For details, see https://github.com/awsdocs/amazon-rekognition-developer-guide/blob/master/LICENSE-SAMPLECODE.)
   
   using System;
   using Amazon.Rekognition;
   using Amazon.Rekognition.Model;
   
   
   public class CelebrityInfo
   {
       public static void Example()
       {
           String id = "nnnnnnnn";
   
           AmazonRekognitionClient rekognitionClient = new AmazonRekognitionClient();
   
           GetCelebrityInfoRequest celebrityInfoRequest = new GetCelebrityInfoRequest()
           {
               Id = id
           };
   
           Console.WriteLine("Getting information for celebrity: " + id);
   
           GetCelebrityInfoResponse celebrityInfoResponse = rekognitionClient.GetCelebrityInfo(celebrityInfoRequest);
   
           //Display celebrity information
           Console.WriteLine("celebrity name: " + celebrityInfoResponse.Name);
           Console.WriteLine("Further information (if available):");
           foreach (String url in celebrityInfoResponse.Urls)
               Console.WriteLine(url);
       }
   }
   ```

------

## GetCelebrityInfo permintaan operasi
<a name="getcelebrityinfo-operation-request"></a>

Berikut ini adalah contoh input dan output JSON untuk `GetCelebrityInfo`. 

Input ke `GetCelebrityInfo` merupakan ID untuk selebriti yang diperlukan.

```
{
    "Id": "nnnnnnn"
}
```

## GetCelebrityInfo respon operasi
<a name="getcelebrityinfo-operation-response"></a>

`GetCelebrityInfo` mengirimkan array (`Urls`) tautan pada informasi tentang selebriti yang diminta.

```
{
    "Name": "Celebrity Name",
    "Urls": [
        "www.imdb.com/name/nmnnnnnnn"
    ]
}
```