需要授權
刪除聯絡人。 請點選此處查看範例。
要求
HTTP 要求
DELETE https://www.googleapis.com/mirror/v1/contacts/id
參數
參數名稱 | 值 | 說明 |
---|---|---|
路徑參數 | ||
id |
string |
聯絡人的 ID。 |
授權
此要求需要獲得下列範圍的授權 (進一步瞭解驗證和授權)。
範圍 |
---|
https://www.googleapis.com/auth/glass.timeline |
要求主體
請勿使用這個方法提供請求主體。
回應
如果成功,這個方法會傳回空白的回應主體。
範例
注意:這個方法適用的程式語言眾多,我們只在此提供部分程式碼範例,完整的支援語言清單請參閱用戶端程式庫頁面。
Java
使用 Java 用戶端程式庫。
import com.google.api.services.mirror.Mirror; import com.google.api.services.mirror.model.Contact; import java.io.IOException; public class MyClass { // ... /** * Delete a contact for the current user. * * @param service Authorized Mirror service. * @param contactId ID of the Contact to delete. */ public static void deleteContact(Mirror service, String contactId) { try { service.contacts().delete(contactId).execute(); } catch (IOException e) { System.err.println("An error occurred: " + e); } } // ... }
.NET
使用 .NET 用戶端程式庫。
using System; using Google.Apis.Mirror.v1; public class MyClass { // ... /// <summary> /// Delete a contact for the current user. /// </summary> /// <param name='service'>Authorized Mirror service.</param> /// <param name='contactId'>ID of the Contact to delete.</param> public static void DeleteContact(MirrorService service, String contactId) { try { service.Contacts.Delete(contactId).Fetch(); } catch (Exception e) { Console.WriteLine("An error occurred: " + e.Message); } } // ... }
PHP
使用 PHP 用戶端程式庫。
/** * Delete a contact for the current user. * * @param Google_MirrorService $service Authorized Mirror service. * @param string $contactId ID of the Contact to delete. */ function deleteContact($service, $contactId) { try { $service->contacts->delete($contactId); } catch (Exception $e) { print 'An error occurred: ' . $e->getMessage(); } }
Python
使用 Python 用戶端程式庫。
from apiclient import errors # ... def delete_contact(service, contact_id): """Delete a contact for the current user. Args: service: Authorized Mirror service. contact_id: ID of the Contact to delete. """ try: service.contacts().delete(contact_id).execute() except errors.HttpError, error: print 'An error occurred: %s' % error
小茹
使用 Ruby 用戶端程式庫。
## # Delete a contact for the current user. # # @param [Google::APIClient] client # Authorized client instance. # @param [String] contact_id # ID of the contact to delete. # @return nil def delete_contact(client, contact_id) mirror = client.discovered_api('mirror', 'v1') result = client.execute( :api_method => mirror.contacts.delete, :parameters => { 'id' => contact_id }) if result.error? puts "An error occurred: #{result.data['error']['message']}" end end
Go
使用 Go 用戶端程式庫。
import ( "code.google.com/p/google-api-go-client/mirror/v1" "fmt" ) // DeleteContact deletes a contact for the current user. func DeleteContact(g *mirror.Service, contactId string) error { err := g.Contacts.Delete(contactId).Do() if err != nil { fmt.Printf("An error occurred: %v\n", err) } return err }
原始 HTTP
不使用用戶端程式庫。
DELETE /mirror/v1/contacts/harold HTTP/1.1
Authorization: Bearer auth token