Yetkilendirme gerektirir
Mevcut bir kişiyi günceller. Örneğe göz atın.
İstek
HTTP isteği
PUT https://www.googleapis.com/mirror/v1/contacts/id
Parametreler
| Parametre adı | Değer | Açıklama |
|---|---|---|
| Yol parametreleri | ||
id |
string |
Kişinin kimliği. |
Yetkilendirme
Bu istek, aşağıdaki kapsamla yetkilendirme gerektiriyor (kimlik doğrulama ve yetkilendirme hakkında daha fazla bilgi edinin).
| Kapsam |
|---|
https://www.googleapis.com/auth/glass.timeline |
İstek içeriği
İstek gövdesinde, aşağıdaki özelliklere sahip bir Kişiler kaynağı sağlayın:
| Mülk adı | Değer | Açıklama | Notlar |
|---|---|---|---|
| Zorunlu Özellikler | |||
acceptCommands[].type |
string |
Bu komutun karşılık gelen işlem türü. İzin verilen değerler:
|
yazılabilir |
displayName |
string |
Bu kişi için gösterilecek ad. | yazabilir |
id |
string |
Bu kişinin kimliği. Bu, uygulama tarafından oluşturulur ve opak jeton olarak işlenir. | yazabilir |
imageUrls[] |
list |
Bir kişi için gösterilecek resim URL'leri grubu. Çoğu kişinin tek bir resmi ancak bir "grup" olur iletişim kutusu en fazla 8 resim URL'si içerebilir ve bu URL'ler yeniden boyutlandırılır ve istemcide bir mozaik şeklinde kırpılır. | yazabilir |
| İsteğe Bağlı Özellikler | |||
acceptCommands[] |
list |
Bir kişinin kullanabileceği sesli menü komutlarının listesi. Glass, her sesli menü komutu için en fazla üç kişiyi gösterir. Bundan fazla sayıda kişi varsa ilgili komut için priority değeri en yüksek olan üç kişi gösterilir. |
yazılabilir |
acceptTypes[] |
list |
Kişinin desteklediği MIME türlerinin listesi. acceptTypes özelliğinden herhangi biri öğedeki ek türlerinden biriyle eşleşirse kişi kullanıcıya gösterilir. AcceptType belirtilmezse tüm öğeler için ilgili kişi gösterilir. | yazabilir |
phoneNumber |
string |
Kişinin birincil telefon numarası. Bu, ülke arama kodu ve alan kodu içeren tam nitelikli bir numara veya yerel bir numara olabilir. | yazılabilir |
priority |
unsigned integer |
Kişi listesinde sıralamayı belirlemek için kişinin önceliği. Yüksek öncelikli kişiler, düşük öncelikli kişilerden önce gösterilir. | yazılabilir |
speakableName |
string |
Bu kişinin adının telaffuzu. Bu kişinin adı, sesli anlamlandırma menüsünün bir parçası olarak okunması gerekiyorsa beklenen telaffuz olarak bu ad kullanılır. Bu özellik, telaffuz edilemeyen karakterler içeren veya görüntü yazımı fonetik olmayan kişi adları için yararlıdır. | yazabilir |
type |
string |
Bu kişinin türü. Bu, kullanıcı arayüzlerinde sıralama yapmak için kullanılır. İzin verilen değerler:
|
yazılabilir |
Yanıt
Başarılı olursa bu yöntem yanıt gövdesinde bir Kişiler kaynağı döndürür.
Örnekler
Not: Bu yöntem için kullanıma sunulan kod örnekleri, desteklenen tüm programlama dillerini kapsamaz (Desteklenen dillerin listesi için istemci kitaplıkları sayfasını inceleyin).
Java
Java istemci kitaplığını kullanır.
import com.google.api.services.mirror.Mirror; import com.google.api.services.mirror.model.Contact; import java.io.IOException; public class MyClass { // ... /** * Rename an existing contact for the current user. * * @param service Authorized Mirror service. * @param contactId ID of the contact to rename. * @param newDisplayName New displayName for the contact. * @return Patched contact on success, {@code null} otherwise. */ public static Contact renameContact(Mirror service, String contactId, String newDisplayName) { try { // Get the latest version of the contact from the API. Contact contact = service.contacts().get(contactId).execute(); contact.setDisplayName(newDisplayName); // Send an update request to the API. return service. contacts().update(contactId, contact).execute(); } catch (IOException e) { System.err.println("An error occurred: " + e); return null; } } // ... }
.NET
.NET istemci kitaplığını kullanır.
using System; using Google.Apis.Mirror.v1; using Google.Apis.Mirror.v1.Data; public class MyClass { // ... /// <summary> /// Rename an existing contact for the current user. /// </summary> /// <param name='service'>Authorized Mirror service.</param> /// <param name='contactId'>ID of the contact to rename.</param> /// <param name='newDisplayName'> /// New displayName for the contact. /// </param> /// <returns> /// Updated contact on success, null otherwise. /// </returns> public static Contact RRenameContact(MirrorService service, String contactId, String newDisplayName) { try { Contact contact = service.Contacts.Get(contactId).Fetch(); contact.DisplayName = newDisplayName; return service.Contacts.Update(contact, contactId).Fetch(); } catch (Exception e) { Console.WriteLine("An error occurred: " + e.Message); return null; } } // ... }
PHP
PHP istemci kitaplığını kullanır.
/** * Rename an existing contact for the current user. * * @param Google_MirrorService $service Authorized Mirror service. * @param string $contactId ID of the contact to rename. * @param string $newDisplayName New displayName for the contact. * @return Google_Contact Updated contact on success, null otherwise. */ function renameContact($service, $contactId, $newDisplayName) { try { $updatedContact = $service->contacts->get($contactId); $updatedContact->setDisplayName($newDisplayName); return $service->contacts->update($contactId, $updatedContact); } catch (Exception $e) { print 'An error occurred: ' . $e->getMessage(); return null; } }
Python
Python istemci kitaplığını kullanır.
from apiclient import errors # ... def rename_contact(service, contact_id, new_display_name): """Rename an existing contact for the current user. Args: service: Authorized Mirror service. contact_id: ID of the contact to rename. new_display_name: New displayName for the contact. Returns: return Patched contact on success, None otherwise. """ try: # Get the latest version of the contact from the API. contact = service.contacts().get(contact_id).execute() contact['displayName'] = new_display_name return service. contacts().update( id=contact_id, body=contact).execute() except errors.HttpError, e: print 'An error occurred: %s' % error return None
Ruby
Ruby istemci kitaplığını kullanır.
## # Rename an existing contact for the current user. # # @param [Google::APIClient] client # Authorized client instance. # @param [String] contact_id # ID of the contact to rename. # @param [String] new_display_name # New displayName for the contact. # @return [Google::APIClient::Schema::Mirror::V1::Contact] # Updated contact on success, nil otherwise. def rename_contact(client, contact_id, new_display_name) mirror = client.discovered_api('mirror', 'v1') # Get the latest version of the contact from the API. result = client.execute( :api_method => mirror.contacts.get, :parameters => { 'id' => contact_id }) if result.success? contact = result.data contact.display_name = new_display_name result = client.execute( :api_method => mirror.contacts.update, :parameters => { 'id' => contact_id }, :body_object => contact) if result.success? return result.data end end puts "An error occurred: #{result.data['error']['message']}" end
Go
Go istemci kitaplığını kullanır.
import ( "code.google.com/p/google-api-go-client/mirror/v1" "fmt" ) // RenameContact renames an existing contact for the current user. func RenameContact(g *mirror.Service, contactId string, newDisplayName string) (*mirror.Contact, error) { s, err := g. Contacts.Get(contactId).Do() if err != nil { fmt.Printf("An error occurred: %v\n", err) return nil, err } s.DisplayName = newDisplayName r, err := g.Contacts.Patch(contactId, s).Do() if err != nil { fmt.Printf("An error occurred: %v\n", err) return nil, err } return r, nil }
Ham HTTP
İstemci kitaplığı kullanmaz.
PUT /mirror/v1/contacts/harold HTTP/1.1 Authorization: Bearer auth token Content-Type: application/json Content-Length: length { "displayName": "Harold Penguin", "imageUrls": ["https://developers.google.com/glass/images/harold.jpg"] }