보강 추가

보강을 사용하면 애플리케이션이 데이터의 구조와 표현을 제어할 수 있습니다. Google 포토의 앨범 내 사진 이를 통해 사용자는 텍스트 또는 위치 주석 및 순서/그룹을 통한 추가 컨텍스트 포함 여러 이미지가 있습니다.

필수 승인 범위

보강을 추가하려면 다음 범위 중 하나 이상이 필요합니다.

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

각 범위에서 enrichAlbum 호출은 생성된 앨범으로만 제한됩니다. 있습니다.

.sharing 범위를 사용하면 enrichAlbum가 상황으로 제한됨 개발자가 공유 앨범의 소유자를 대행할 때 사용됩니다.

보강 유형

Google 포토는 앨범에서 텍스트, 위치, 지도가 있습니다.

텍스트 보강

텍스트 보강은 콘텐츠에 주석을 달기 위해 삽입할 수 있는 일반 텍스트 문자열입니다. 앨범

Google 포토에 표시된 텍스트 보강 스크린샷

위치 보강

위치 보강은 삽입할 수 있는 장소의 마커 및 이름입니다. 위치에 주석을 달 수 있습니다.

Google 포토에 표시되는 위치 보강 스크린샷

지도 보강

지도 보강은 지정된 출발지와 목적지가 있는 지도로서 앨범에 삽입됩니다.

Google 포토에 표시되는 지도 보강 스크린샷

위치

미디어 항목과 앨범 보강을 삽입하려면 앨범의 위치를 지정합니다. 미디어 항목의 경우 위치는 선택사항이지만 앨범에 대해서는 지정해야 합니다. 강화해야 합니다.

게재순위는 다음 경우에만 지정할 수 있습니다. 미디어 항목 만들기 보강을 추가할 수 있습니다. 앨범의 기존 미디어 항목은 재구성할 수 없으므로 항목을 추가할 때 항목의 위치를 설정하는 것이 중요합니다.

앨범의 시작

미디어/보강을 위해 앨범 시작 부분에 절대적 있습니다.

앨범의 마지막

미디어/보강 항목을 절대적인 방법으로 앨범 끝에 추가할 수 있습니다. 있습니다.

미디어 항목 기준

다음 날짜 이후에 시작되는 미디어 항목과 관련하여 미디어/보강 항목을 추가할 수 있습니다. 확인할 수 있습니다.

보강 항목 기준

보강 항목 시작과 관련하여 미디어/보강 항목을 추가할 수 있습니다. 를 추가할 수 있습니다.

앨범에 보강 추가

보강은 한 번에 하나씩 추가되며 앨범의 위치에 추가해야 합니다. 앨범에 보강을 추가하려면 다음을 호출합니다. 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",
  }
}

자바

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"
}

자바

// 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"
    }
  }
}

자바

// 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);

지도 보강

지도 보강에서는 이름과 위도로 구성된 두 위치를 표시합니다. 볼 수 있습니다. 위치 보강과 마찬가지로 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"
    }
  }
}

자바

// 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",
}

자바

AlbumPosition albumPosition = AlbumPositionFactory.createFirstInAlbum();

PHP

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

앨범의 마지막

위치 LAST_IN_ALBUM는 앨범의 끝부분을 나타냅니다. 여기에 있는 상품 사용자에게 마지막으로 표시됩니다

REST

{
  "position": "LAST_IN_ALBUM",
}

자바

AlbumPosition albumPosition = AlbumPositionFactory.createLastInAlbum();

PHP

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

미디어 항목 기준

위치 relativeMediaItem를 지정하면 미디어 항목입니다. 항목은 지정된 미디어 항목 뒤에 추가됩니다.

REST

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

자바

AlbumPosition albumPosition = AlbumPositionFactory.createAfterMediaItem(mediaItemId);

PHP

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

보강 항목 기준

relativeEnrichmentItemId를 지정하면 보강 항목을 선택합니다 항목은 지정된 보강 항목 뒤에 추가됩니다.

REST

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

자바

AlbumPosition albumPosition = AlbumPositionFactory.createAfterEnrichmentItem(enrichmentItemId);

PHP

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

보강 수정

현재 보강을 수정할 수 있는 방법은 없습니다. 그러나 한 번 강화하여 만들어져 앨범에 추가된 경우 사용자는 보강 작업을 수정할 수 있습니다. 사진을 공유할 수 있습니다.