고급 사용자 서비스

고급 피플 서비스를 사용하면 People API: Apps Script에서 사용 가능합니다. 이 API를 사용하면 로그인한 사용자의 연락처 데이터를 생성, 읽기, 업데이트하고 프로필을 읽습니다. Google 사용자용 데이터입니다.

참조

이 서비스에 대한 자세한 내용은 People API 참조 문서를 확인하세요. Apps Script의 모든 고급 서비스와 마찬가지로 고급 사용자 서비스는 공개 API와 동일한 객체, 메서드, 매개변수를 지원합니다. 자세한 내용은 메서드 서명 확인 방법을 참조하세요.

문제를 신고하고 기타 지원을 받으려면 다음을 참조하세요. 사용자 v1 지원 가이드

샘플 코드

아래 샘플 코드는 API의 버전 1을 사용합니다.

사용자 연결 가져오기

사용자의 연락처에 있는 사용자 목록을 가져오려면 다음 안내를 따르세요. 다음 코드를 사용합니다.

advanced/people.gs
/**
 * Gets a list of people in the user's contacts.
 * @see https://developers.google.com/people/api/rest/v1/people.connections/list
 */
function getConnections() {
  try {
    // Get the list of connections/contacts of user's profile
    const people = People.People.Connections.list('people/me', {
      personFields: 'names,emailAddresses'
    });
    // Print the connections/contacts
    console.log('Connections: %s', JSON.stringify(people, null, 2));
  } catch (err) {
    // TODO (developers) - Handle exception here
    console.log('Failed to get the connection with an error %s', err.message);
  }
}

사용자를 가져올 사용자 가져오기

사용자의 프로필을 가져오려면 https://www.googleapis.com/auth/userinfo.profile 범위를 지정합니다. 명시적 범위 추가 안내appsscript.json 매니페스트 파일에 추가합니다. 범위가 추가되면 다음 코드를 참조하세요.

advanced/people.gs
/**
 * Gets the own user's profile.
 * @see https://developers.google.com/people/api/rest/v1/people/getBatchGet
 */
function getSelf() {
  try {
    // Get own user's profile using People.getBatchGet() method
    const people = People.People.getBatchGet({
      resourceNames: ['people/me'],
      personFields: 'names,emailAddresses'
      // Use other query parameter here if needed
    });
    console.log('Myself: %s', JSON.stringify(people, null, 2));
  } catch (err) {
    // TODO (developer) -Handle exception
    console.log('Failed to get own profile with an error %s', err.message);
  }
}

Google 계정을 만들 사용자 가져오기

Google 계정의 사용자 정보를 확인하려면 다음 안내를 따르세요. 다음 코드를 사용합니다.

advanced/people.gs
/**
 * Gets the person information for any Google Account.
 * @param {string} accountId The account ID.
 * @see https://developers.google.com/people/api/rest/v1/people/get
 */
function getAccount(accountId) {
  try {
    // Get the Account details using account ID.
    const people = People.People.get('people/' + accountId, {
      personFields: 'names,emailAddresses'
    });
    // Print the profile details of Account.
    console.log('Public Profile: %s', JSON.stringify(people, null, 2));
  } catch (err) {
    // TODO (developer) - Handle exception
    console.log('Failed to get account with an error %s', err.message);
  }
}