เพิ่มคุณค่า

การปรับปรุงข้อมูลช่วยให้แอปพลิเคชันของคุณควบคุมโครงสร้างและการนำเสนอรูปภาพภายในอัลบั้มใน Google Photos ได้ ซึ่งจะช่วยให้คุณนำเสนอบริบทเพิ่มเติมแก่ผู้ใช้ผ่านคำอธิบายประกอบข้อความหรือสถานที่ และรูปภาพลำดับ/จัดกลุ่มที่บอกเล่าเรื่องราวร่วมกันได้

ขอบเขตการให้สิทธิ์ที่จำเป็น

ต้องมีขอบเขตต่อไปนี้อย่างน้อย 1 รายการเพื่อเพิ่มความสมบูรณ์

  • photoslibrary.appendonly
  • photoslibrary.library
  • photoslibrary.sharing

ในแต่ละขอบเขต การเรียก enrichAlbum จะจำกัดไว้เฉพาะอัลบั้มที่แอปสร้างขึ้นเท่านั้น

เมื่อใช้ขอบเขต .sharing enrichAlbum จะถูกจำกัดไว้ในสถานการณ์ที่นักพัฒนาซอฟต์แวร์ดำเนินการในนามของเจ้าของอัลบั้มที่แชร์

ประเภทการเสริมภูมิคุ้มกัน

Google Photos รองรับคุณค่า 3 ประเภทในอัลบั้ม ได้แก่ ข้อความ สถานที่ และแผนที่

ข้อความที่สมบูรณ์ขึ้น

การปรับปรุงข้อความเป็นสตริงข้อความธรรมดาที่สามารถแทรกเพื่อกำกับอัลบั้ม

ภาพหน้าจอของข้อความที่สมบูรณ์ใน Google Photos

การปรับปรุงสถานที่ตั้ง

การเติมข้อมูลสถานที่คือเครื่องหมายและชื่อสถานที่ซึ่งสามารถแทรกเพื่อใส่คำอธิบายประกอบให้กับสถานที่

ภาพหน้าจอแสดงสถานที่ที่สมบูรณ์ใน Google Photos

การปรับปรุงแผนที่

แผนที่ที่สมบูรณ์ขึ้นคือแผนที่ซึ่งมีต้นทางและปลายทางที่ระบุไว้ ซึ่งสามารถแทรกเข้าไปในอัลบั้มได้

ภาพหน้าจอของแผนที่ที่สมบูรณ์ขึ้นซึ่งแสดงใน Google Photos

ตำแหน่ง

หากต้องการแทรกรายการสื่อและความสมบูรณ์ของอัลบั้ม ให้ระบุตำแหน่งของอัลบั้ม ตำแหน่งเป็นตัวเลือกที่ไม่บังคับสำหรับรายการสื่อ แต่ต้องระบุสำหรับการเพิ่มประสิทธิภาพอัลบั้ม

คุณจะระบุตำแหน่งได้เมื่อสร้างรายการสื่อหรือเพิ่มคุณค่าลงไปเท่านั้น รายการสื่อที่มีอยู่ในอัลบั้มจะไม่สามารถจัดระเบียบใหม่ได้ ดังนั้นจึงจำเป็นที่จะต้องกำหนดตำแหน่งของรายการเมื่อมีการเพิ่มเข้ามา

เริ่มต้นอัลบั้ม

รายการสื่อ/การเพิ่มประสิทธิภาพสามารถเพิ่มไปยังจุดเริ่มต้นของอัลบั้มเป็นการจัดตำแหน่งแบบสัมบูรณ์ได้

จบอัลบั้ม

สามารถเพิ่มรายการสื่อ/การเพิ่มประสิทธิภาพไปยังตอนท้ายของอัลบั้มให้เป็นตำแหน่งสัมบูรณ์

เกี่ยวข้องกับรายการสื่อ

สามารถเพิ่มสื่อ/รายการเสริมโดยสัมพันธ์กับรายการสื่อที่เริ่มต้นหลังจากตำแหน่งในอัลบั้ม

เกี่ยวข้องกับไอเทมเพิ่มคุณค่า

สามารถเพิ่มสื่อ/รายการเสริมอาหาร โดยสัมพันธ์กับไอเทมเพิ่มคุณค่าหลังจากตำแหน่งในอัลบั้ม

การเพิ่มเนื้อหาลงในอัลบั้ม

การแต่งเติมจะเพิ่มทีละรายการและต้องเพิ่มลงในตำแหน่งในอัลบั้ม หากต้องการเพิ่มอรรถรสให้กับอัลบั้ม โปรดโทร albums.addEnrichment

หากคำขอประสบความสำเร็จ คำขอดังกล่าวจะส่งคืน id ของรายการเสริม ซึ่งสามารถใช้จัดตำแหน่งรายการสื่อหรือการเพิ่มคุณค่าอื่นๆ ได้

REST

คำขอ POST มีดังนี้

POST https://photoslibrary.googleapis.com/v1/albums/album-id:addEnrichment
Content-type: application/json
Authorization: Bearer oauth2-token
request-body

เนื้อหาของคำขอประกอบไปด้วยรายการเสริมและตำแหน่งของรายการดังกล่าว

{
  "newEnrichmentItem": {
    enrichment-to-be-added
  },
  "albumPosition": {
    position-of-enrichment
}

ต่อไปนี้คือตัวอย่างคำตอบ

{
  "enrichmentItem": {
    "id": "enrichment-item-id",
  }
}

Java

try {
  // Create the enrichment using the NewEnrichmentItemFactory helper
  NewEnrichmentItem newEnrichmentItem = NewEnrichmentItemFactory.createTextEnrichment("");

  // Set the position of the enrichment within the album
  AlbumPosition albumPosition = AlbumPositionFactory.createFirstInAlbum();

  // To add an enrichment, specify the album, the enrichment item,
  // and the position in the album where the enrichment is to be added
  AddEnrichmentToAlbumResponse response = photosLibraryClient
      .addEnrichmentToAlbum(albumId, newEnrichmentItem, albumPosition);
  // The response contains an EnrichmentItem
  // whose ID can be used to position media items or other enrichments
  EnrichmentItem enrichmentItem = response.getEnrichmentItem();
  String itemId = enrichmentItem.getId();
} catch (ApiException e) {
  // Handle error
}

PHP

// Create the enrichment item using the PhotosLibraryResourceFactory helper
$newEnrichmentItem = PhotosLibraryResourceFactory::newEnrichmentItemWithText("");
// ...
// Set the position of the enrichment within the album
$position = new AlbumPosition();
// ...
try {
    // To add an enrichment, specify the album, the enrichment item,
    // and the position in the album where the enrichment is to be added
    $response = $photosLibraryClient->addEnrichmentToAlbum($albumId, $newEnrichmentItem, $position);
    // The response contains an EnrichmentItem
    // whose ID can be used to position media items or other enrichments
    $enrichmentItem = $response->getEnrichmentItem();
    $itemId = $enrichmentItem->getId();

} catch (\Google\ApiCore\ApiException $e) {
    // Handle error
}

การเพิ่มประสิทธิภาพที่รองรับ

ข้อความที่สมบูรณ์ขึ้น

ข้อความที่สมบูรณ์ประกอบด้วยสตริงข้อความเดียว (ไม่เกิน 1,000 อักขระ) ดังที่แสดงในตัวอย่างต่อไปนี้

REST

{
  "text": "Text to be shown"
}

Java

// Use the NewEnrichmentItemFactory helper to create a text enrichment item
NewEnrichmentItem newEnrichmentItem =
    NewEnrichmentItemFactory.createTextEnrichment("text to be shown");

PHP

$newEnrichmentItem = PhotosLibraryResourceFactory::newEnrichmentItemWithText("text to be shown");

การปรับปรุงสถานที่ตั้ง

ความสมบูรณ์ของสถานที่ประกอบด้วยชื่อสถานที่ตั้งที่กำหนดเองและตำแหน่งละติจูดและลองจิจูด locationName มีอักขระได้ไม่เกิน 500 ตัว

REST

{
  "location": {
    "locationName": "Australia",
    "latlng": {
      "latitude": "-21.197",
      "longitude": "95.821"
    }
  }
}

Java

// Use the NewEnrichmentItemFactory helper to create a location enrichment
// with the name, latitude, and longitude of the location
NewEnrichmentItem newEnrichmentItem =
    NewEnrichmentItemFactory.createLocationEnrichment("Australia", -21.197, 95.821);

PHP

// Create a new location object and set the name, latitude, and longitude of the location
$newLocation = new Location();
$newLocation->setLocationName("Australia");
$newLocation->setLatlng((new LatLng())->setLatitude(-21.197)->setLongitude(95.821));

$newEnrichmentItem = PhotosLibraryResourceFactory::newEnrichmentItemWithLocation($newLocation);

การปรับปรุงแผนที่

ความสมบูรณ์ของแผนที่จะแสดงสถานที่ 2 แห่ง แต่ละแห่งประกอบด้วยชื่อและละติจูดและลองจิจูด locationName ภายในต้นทางและ destination ต้องมีความยาวไม่เกิน 500 อักขระ เช่นเดียวกับการปรับปรุงตำแหน่ง

REST

{
  "origin": {
    "locationName": "Australia",
    "latlng": {
      "latitude": "-21.197",
      "longitude": "95.821"
    }
  },
  "destination": {
    "locationName": "San Francisco",
    "latlng": {
      "latitude": "37.757",
      "longitude": "122.507"
    }
  }
}

Java

// Use the NewEnrichmentItemFactory helper to create a map enrichment item for
// an origin and a destination location
NewEnrichmentItem newEnrichmentItem = NewEnrichmentItemFactory.createMapEnrichment(
    "Australia", -21.197, 95.821, // origin
    "San Francisco", 37.757, 122.507 // destination
);

PHP

// Create two new location objects to create a map enrichment item
// for an origin and a destination location
$locationAustralia = new Location();
$locationAustralia->setLocationName("Australia");
$locationAustralia->setLatlng((new LatLng())->setLatitude(-21.197)->setLongitude(95.821));

$locationSanFrancisco = new Location();
$locationSanFrancisco->setLocationName("San Francisco");
$locationSanFrancisco->setLatlng((new LatLng())->setLatitude(37.757)->setLongitude(122.507));

$newEnrichmentItem =
  PhotosLibraryResourceFactory::newEnrichmentItemWithMap($locationAustralia, $locationSanFrancisco);

การกำหนดตำแหน่งที่รองรับ

เริ่มต้นอัลบั้ม

ตำแหน่ง FIRST_IN_ALBUM หมายถึงจุดเริ่มต้นของอัลบั้ม รายการที่แสดงที่นี่จะแสดงต่อผู้ใช้ก่อน

REST

{
  "position": "FIRST_IN_ALBUM",
}

Java

AlbumPosition albumPosition = AlbumPositionFactory.createFirstInAlbum();

PHP

$albumPosition = new AlbumPosition();
$albumPosition->setPosition(PositionType::FIRST_IN_ALBUM);

จบอัลบั้ม

ส่วน LAST_IN_ALBUM หมายถึงช่วงท้ายของอัลบั้ม รายการที่แสดงที่นี่จะแสดงต่อผู้ใช้เป็นลำดับสุดท้าย

REST

{
  "position": "LAST_IN_ALBUM",
}

Java

AlbumPosition albumPosition = AlbumPositionFactory.createLastInAlbum();

PHP

$albumPosition = new AlbumPosition();
$albumPosition->setPosition(PositionType::LAST_IN_ALBUM);

เกี่ยวข้องกับรายการสื่อ

การระบุตำแหน่ง relativeMediaItem หมายถึงตำแหน่งที่สัมพันธ์กับรายการสื่อ ระบบจะเพิ่มรายการหลังรายการสื่อที่ระบุ

REST

{
  "position": "after-media-item",
  "relativeMediaItemId": "media-item-id"
}

Java

AlbumPosition albumPosition = AlbumPositionFactory.createAfterMediaItem(mediaItemId);

PHP

$albumPosition = PhotosLibraryResourceFactory::albumPositionAfterMediaItem($mediaItemId);

เกี่ยวข้องกับไอเทมเพิ่มคุณค่า

การระบุ relativeEnrichmentItemId จะหมายถึงตำแหน่งที่สัมพันธ์กับรายการการเพิ่มประสิทธิภาพ ระบบจะเพิ่มไอเทมไว้หลังรายการเสริมที่ระบุไว้

REST

{
  "position": "after-enrichment-item",
  "relativeEnrichmentItemId": "enrichment-item-id"
}

Java

AlbumPosition albumPosition = AlbumPositionFactory.createAfterEnrichmentItem(enrichmentItemId);

PHP

$albumPosition = PhotosLibraryResourceFactory::albumPositionAfterEnrichmentItem($enrichmentItemId);

การแก้ไขเนื้อหา

ปัจจุบันยังไม่มีวิธีแก้ไขการเพิ่มคุณค่า แต่เมื่อสร้างส่วนที่สมบูรณ์และเพิ่มลงในอัลบั้มแล้ว ผู้ใช้จะปรับแต่งรูปดังกล่าวผ่านแอป Google Photos ได้