Subscriptions: delete

Yêu cầu uỷ quyền

Xoá gói thuê bao. Xem ví dụ.

Yêu cầu

Yêu cầu HTTP

DELETE https://www.googleapis.com/mirror/v1/subscriptions/id

Các tham số

Tên thông số Giá trị Mô tả
Tham số đường dẫn
id string Mã của gói thuê bao.

Ủy quyền

Yêu cầu này cần được cho phép nếu có phạm vi sau (đọc thêm về quy trình xác thực và cấp phép).

Phạm vi
https://www.googleapis.com/auth/glass.timeline

Nội dung yêu cầu

Đừng cung cấp nội dung yêu cầu bằng phương thức này.

Phản hồi

Nếu thành công, phương thức này sẽ trả về nội dung phản hồi trống.

Ví dụ

Lưu ý: Các đoạn mã mẫu của phương thức này không phải là ví dụ cho mọi ngôn ngữ lập trình được hỗ trợ (xem trang thông tin về các thư viện dùng cho ứng dụng để biết danh sách các ngôn ngữ được hỗ trợ).

Java

Sử dụng thư viện ứng dụng Java.

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

import java.io.IOException;

public class MyClass {
  // ...

  /**
   * Delete a subscription to a collection.
   * 
   * @param service Authorized Mirror service.
   * @param collection Collection to unsubscribe from (supported values are
   *        "timeline" and "locations").
   */
  public static void unsubscribeFromNotifications(Mirror service, String collection) {
    try {
      service.subscriptions().delete(collection).execute();
    } catch (IOException e) {
      System.err.println("An error occurred: " + e);
    }
  }

  // ...
}

.NET

Sử dụng thư viện ứng dụng .NET.

using System;

using Google.Apis.Mirror.v1;

public class MyClass {
  // ...

  /// <summary>
  /// Delete a subscription to a collection.
  /// </summary>
  /// <param name='service'>Authorized Mirror service.</param>
  /// <param name='collection'>
  /// Collection to unsubscribe from (supported values are "timeline" and
  /// "locations").
  /// </param>
  public static void UnsubscribeFromNotifications(MirrorService service,
      String collection) {
    try {
      service.Subscriptions.Delete(collection).Fetch();
    } catch (Exception e) {
      Console.WriteLine("An error occurred: " + e.Message);
    }
  }

  // ...
}

PHP

Sử dụng thư viện ứng dụngPHP.

/**
 * Delete a subscription to a collection.
 *
 * @param Google_MirrorService $service Authorized Mirror service.
 * @param string $collection Collection to unsubscribe from (supported values
 *                           are "timeline" and "locations").
 */
function unsubscribeFromNotifications($service, $collection) {
  try {
    $service->subscriptions->delete($collection);
  } catch (Exception $e) {
    print 'An error occurred: ' . $e->getMessage();
  }
}

Python

Sử dụng thư viện ứng dụng Python.

from apiclient import errors
# ...

def unsubscribe_from_notifications(service, collection):
  """Delete a subscription to a collection.

  Args:
    service: Authorized Mirror service.
    collection: Collection to unsubscribe from (supported values are
                "timeline" and "locations"
  """
  try:
    service.subscriptions().delete(collection).execute()
  except errors.HttpError, error:
    print 'An error occurred: %s' % error

Ruby

Sử dụng thư viện ứng dụng Ruby.

##
# Delete a subscription to a collection.
#
# @param [Google::APIClient] client
#   Authorized client instance.
# @param [String] collection
#   Collection to unsubscribe from (supported values are "timeline" and
#   "locations").
# @return nil
def unsubscribe_from_notifications(client, collection)
  mirror = client.discovered_api('mirror', 'v1')
  result = client.execute(
    :api_method => mirror.subscriptions.delete,
    :parameters => { 'id' => collection })
  if result.error?
    puts "An error occurred: #{result.data['error']['message']}"
  end
end

Go

Sử dụng Thư viện ứng dụng Go.

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

// UnsubscribeFromNotifications deletes a subscription to a collection.
func UnsubscribeFromNotifications(g *mirror.Service, collection string) error {
	err := g.Subscriptions.Delete(collection).Do()
	if err != nil {
		fmt.Printf("An error occurred: %v\n", err)
		return err
	}
	return nil
}

HTTP thô

Không sử dụng thư viện ứng dụng.

DELETE /mirror/v1/subscriptions/timeline HTTP/1.1
Authorization: Bearer auth token