Contacts: list

অনুমোদন প্রয়োজন

প্রমাণীকৃত ব্যবহারকারীর জন্য পরিচিতির একটি তালিকা পুনরুদ্ধার করে। একটি উদাহরণ দেখুন

অনুরোধ

HTTP অনুরোধ

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

অনুমোদন

এই অনুরোধের জন্য নিম্নলিখিত সুযোগের সাথে অনুমোদনের প্রয়োজন ( প্রমাণিকরণ এবং অনুমোদন সম্পর্কে আরও পড়ুন )।

ব্যাপ্তি
https://www.googleapis.com/auth/glass.timeline

শরীরের অনুরোধ

এই পদ্ধতির সাথে একটি অনুরোধ সংস্থা সরবরাহ করবেন না।

প্রতিক্রিয়া

সফল হলে, এই পদ্ধতিটি নিম্নলিখিত কাঠামো সহ একটি প্রতিক্রিয়া বডি প্রদান করে:

{
  "kind": "mirror#contacts",
  "items": [
    contacts Resource
  ]
}
সম্পত্তির নাম মান বর্ণনা মন্তব্য
kind string সম্পদের ধরন। এটি সর্বদা mirror#contacts
items[] list যোগাযোগ তালিকা.

উদাহরণ

দ্রষ্টব্য: এই পদ্ধতির জন্য উপলব্ধ কোড উদাহরণগুলি সমস্ত সমর্থিত প্রোগ্রামিং ভাষার প্রতিনিধিত্ব করে না (সমর্থিত ভাষার তালিকার জন্য ক্লায়েন্ট লাইব্রেরি পৃষ্ঠা দেখুন)।

জাভা

জাভা ক্লায়েন্ট লাইব্রেরি ব্যবহার করে।

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

import java.io.IOException;

public class MyClass {
  // ...

  /**
   * Print all contacts for the current user.
   * 
   * @param service Authorized Mirror service.
   */
  public void printAllContacts(Mirror service) {
    try {
      ContactsListResponse contacts = service.contacts().list().execute();

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

  // ...
}

.নেট

.NET ক্লায়েন্ট লাইব্রেরি ব্যবহার করে।

using System;

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

public class MyClass {
  // ...

  /// <summary>
  /// Print all contacts for the current user.
  /// </summary>
  /// <param name='service'>Authorized Mirror service.</param>
  public static void PrintAllContacts(MirrorService service) {
    try {
      ContactsListResponse contacts =
          service.Contacts.List().Fetch();

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

  // ...
}

পিএইচপি

পিএইচপি ক্লায়েন্ট লাইব্রেরি ব্যবহার করে।

/**
 * Print all contacts for the current user.
 *
 * @param Google_MirrorService service Authorized Mirror service.
 */
function printAllContacts($service) {
  try {
    $contacts = $service->contacts->listContacts();

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

পাইথন

পাইথন ক্লায়েন্ট লাইব্রেরি ব্যবহার করে।

from apiclient import errors
# ...

def print_all_contacts(service):
  """Print all contacts for the current user.

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

রুবি

রুবি ক্লায়েন্ট লাইব্রেরি ব্যবহার করে।

##
# Print all contacts for the current user.
#
# @param [Google::APIClient] client
#   Authorized client instance.
# @return nil
def print_all_contacts(client)
  mirror = client.discovered_api('mirror', 'v1')
  result = client.execute(:api_method => mirror.contacts.list)
  if result.success?
    contacts = result.data
    contacts.items.each do |contact|
      puts "Contact ID: #{contact.id}"
      puts "  > displayName: #{contact.display_name}"
      contact['imageUrls'].each do |image_url|
        puts "  > imageUrl: #{image_url}"
      end
    end
  else
    puts "An error occurred: #{result.data['error']['message']}"
  end
end

যাওয়া

Go ক্লায়েন্ট লাইব্রেরি ব্যবহার করে।

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

// PrintAllContacts prints all contacts for the current user.
func PrintAllContacts(g *mirror.Service) error {
        s, err := g.Contacts.List().Do()
        if err != nil {
                fmt.Printf("An error occurred: %v\n", err)
                return err
        }
        for _, st := range s.Items {
                fmt.Printf("Contact ID: %s\n", st.Id)
                fmt.Printf("  > displayName: %s\n", st.DisplayName)
                for _, i := range st.ImageUrls {
                    fmt.Printf("  > imageUrl: %s\n", i)
                }
        }
        return nil
}

কাঁচা HTTP

একটি ক্লায়েন্ট লাইব্রেরি ব্যবহার করে না।

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