Contacts: get

認証が必要です

ID で単一の連絡先を取得します。例を見る

リクエスト

HTTP リクエスト

GET https://www.googleapis.com/mirror/v1/contacts/id

パラメータ

パラメータ名 説明
パスパラメータ
id string 連絡先の ID。

承認

このリクエストは、次のスコープでの承認が必要です(認証と承認の詳細をご確認ください)。

スコープ
https://www.googleapis.com/auth/glass.timeline

リクエスト本文

このメソッドをリクエストの本文に含めないでください。

レスポンス

成功すると、このメソッドはレスポンスの本文で Contacts リソースを返します。

注: このメソッドで使用可能なコード例では、サポートされているプログラミング言語すべての例を示しているわけではありません(サポートされている言語の一覧については、クライアント ライブラリ ページをご覧ください)。

Java

Java クライアント ライブラリを使用します。

import com.google.api.services.mirror.Mirror;
import com.google.api.services.mirror.model.Contact;

import java.io.IOException;

public class MyClass {
  // ...

  /**
   * Print information for a contact.
   * 
   * @param service Authorized Mirror service.
   * @param contactId ID of the Contact to print information for.
   */
  public static void printContact(Mirror service, String contactId) {
    try {
      Contact contact = service.contacts().get(contactId).execute();

      System.out.println("Contact displayName: " + contact.getDisplayName());
      if (contact.getImageUrls() != null) {
        for (String imageUrl : contact.getImagesUrls()) {
          System.out.println("Contact imageUrl: " + imageUrl);
        }
      }
    } catch (IOException e) {
      System.err.println("An error occurred: " + e);
    }
  }

  // ...
}

.NET

.NET クライアント ライブラリを使用します。

using System;

using Google.Apis.Mirror.v1;
using Google.Apis.Mirror.v1.Data;

public class MyClass {
  // ...

  /// <summary>
  /// Print information for a contact.
  /// </summary>
  /// <param name='service'>Authorized Mirror service</param>
  /// <param name='contactId'>
  /// ID of the Contact to print information for.
  /// </param>
  public static void PrintContact(MirrorService service,
      String contactId) {
    try {
      Contact contact = service.Contacts.Get(contactId).Fetch();

      Console.WriteLine(
          "Contact displayName: " + contact.DisplayName);
      if (contact.ImageUrls != null) {
        foreach (String imageUrl in contact.ImageUrls) {
          Console.WriteLine("Contact imageUrl: " + imageUrl);
        }
      }
    } catch (Exception e) {
      Console.WriteLine("An error occurred: " + e.Message);
    }
  }

  // ...
}

PHP

PHP クライアント ライブラリを使用します。

/*
 * Print information for a contact.
 *
 * @param Google_MirrorService $service Authorized Mirror service.
 * @param string $contactId ID of the Contact to print information for.
 */
function printContact($service, $contactId) {
  try {
    $contact = $service->contacts->get($contactId);

    print 'Contact displayName: ' . $contact->getDisplayName();
    if ($contact->getImageUrls() != null) {
      foreach ($contact->getImageUrls() as $imageUrl) {
        print 'Contact imageUrl: ' . $imageUrl;
      }
    }
  } catch (Exception $e) {
    print 'An error occurred: ' . $e->getMessage();
  }
}

Python

Python クライアント ライブラリを使用します。

from apiclient import errors
# ...

def print_contact(service, contact_id):
  """Print information for a contact.

  Args:
    service: Authorized Mirror service.
    contact_id: ID of the Contact to print information for.
  """
  try:
    contact = service.contacts().get(id= contact_id).execute()
    print 'Contact displayName: %s' % contact.get('displayName')
    for image_url in contact.get('imageUrls', []):
      print 'Contact imageUrl: %s' % image_url
  except errors.HttpError, error:
    print 'An error occurred: %s' % error

Ruby

Ruby クライアント ライブラリを使用します。

##
# Print information for a contact.
#
# @param [Google::APIClient] client
#   Authorized client instance.
# @param [String] contact_id
#   ID of the contact to print information for.
# @return nil
def print_contact(client, contact_id)
  mirror = client.discovered_api('mirror', 'v1')
  result = client.execute(
    :api_method => mirror.contacts.get,
    :parameters => { 'id' => contact_id })
  if result.success?
    contact = result.data
    puts "Contact displayName: #{contact.displayName}"
    contact.image_urls.each do |image_url|
      puts "Contact imageUrl: #{image_url}"
    end
  else
    puts "An error occurred: #{result.data['error']['message']}"
  end
end

Go

Go クライアント ライブラリを使用します。

import (
        "code.google.com/p/google-api-go-client/mirror/v1"
        "fmt"
)

// PrintContact prints information for a contact.
func PrintContact(g *mirror.Service, contactId string) error {
        s, err := g.Contacts.Get(contactId).Do()
        if err != nil {
                fmt.Printf("An error occurred: %v\n", err)
                return err
        }
        fmt.Printf("Contact displayName: %s\n", s.DisplayName)
        for _, i := range s.ImageUrls {
                fmt.Printf("Contact imageUrl: %s\n", i)
        }
        return nil
}

未加工の HTTP

クライアント ライブラリは使用しません。

GET /mirror/v1/contacts/harold HTTP/1.1
Authorization: Bearer auth token