Subscriptions: delete
تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
يتطلّب تفويضًا
يؤدي هذا الإجراء إلى حذف اشتراك.
اطّلِع على مثال.
الطلب
طلب HTTP
DELETE https://www.googleapis.com/mirror/v1/subscriptions/id
المعلمات
اسم المعلَمة |
القيمة |
الوصف |
مَعلمات المسار |
id |
string |
رقم تعريف الاشتراك.
|
التفويض
يتطلب هذا الطلب تفويضًا بالنطاق التالي (مزيد من المعلومات عن المصادقة والترخيص).
النطاق |
https://www.googleapis.com/auth/glass.timeline |
نص الطلب
لا توفِّر نصًّا للطلب باستخدام هذه الطريقة.
الإجابة
في حال نجاح هذه الطريقة، سيتم عرض نص استجابة فارغ.
أمثلة
ملاحظة: إنّ الأمثلة المرتبطة بالرموز والمتوفرة لهذه الطريقة لا تمثّل كل لغات البرمجة المتوافقة (يُرجى مراجعة صفحة مكتبات البرامج للاطّلاع على قائمة باللغات المتوافقة).
Java
تستخدم مكتبة برامج 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.
لاستخدام مكتبة برامج .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
لاستخدام مكتبة برامج PHP
/**
* 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
تستخدم مكتبة برامج 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
تستخدم مكتبة برامج 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.
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 غير منسق
لا يستخدم مكتبة برامج.
DELETE /mirror/v1/subscriptions/timeline HTTP/1.1
Authorization: Bearer auth token
إنّ محتوى هذه الصفحة مرخّص بموجب ترخيص Creative Commons Attribution 4.0 ما لم يُنصّ على خلاف ذلك، ونماذج الرموز مرخّصة بموجب ترخيص Apache 2.0. للاطّلاع على التفاصيل، يُرجى مراجعة سياسات موقع Google Developers. إنّ Java هي علامة تجارية مسجَّلة لشركة Oracle و/أو شركائها التابعين.
تاريخ التعديل الأخير: 2024-07-12 (حسب التوقيت العالمي المتفَّق عليه)
[null,null,["تاريخ التعديل الأخير: 2024-07-12 (حسب التوقيت العالمي المتفَّق عليه)"],[[["\u003cp\u003eDeletes a specific subscription using its ID with a DELETE request to the Google Mirror API.\u003c/p\u003e\n"],["\u003cp\u003eRequires authorization with the \u003ccode\u003ehttps://www.googleapis.com/auth/glass.timeline\u003c/code\u003e scope.\u003c/p\u003e\n"],["\u003cp\u003eThe request does not require a body and returns an empty response upon success.\u003c/p\u003e\n"],["\u003cp\u003eCode examples in various languages demonstrate how to use respective client libraries to make the deletion request.\u003c/p\u003e\n"],["\u003cp\u003eRaw HTTP request example highlights the necessary DELETE endpoint and authorization header.\u003c/p\u003e\n"]]],[],null,["# Subscriptions: delete\n\n**Requires [authorization](#auth)**\n\nDeletes a subscription.\n[See an example](#examples).\n\nRequest\n-------\n\n### HTTP request\n\n```\nDELETE https://www.googleapis.com/mirror/v1/subscriptions/id\n```\n\n### Parameters\n\n| Parameter name | Value | Description |\n|----------------|----------|-----------------------------|\n| **Path parameters** |||\n| `id` | `string` | The ID of the subscription. |\n\n### Authorization\n\nThis request requires authorization with the following scope ([read more about authentication and authorization](/glass/authorization)).\n\n| Scope |\n|--------------------------------------------------|\n| `https://www.googleapis.com/auth/glass.timeline` |\n\n### Request body\n\nDo not supply a request body with this method.\n\nResponse\n--------\n\nIf successful, this method returns an empty response body.\n\nExamples\n--------\n\n**Note:** The code examples available for this method do not represent all supported programming languages (see the [client libraries page](/glass/tools-downloads/client-libraries) for a list of supported languages). \n\n### Java\n\nUses the [Java client library](/glass/tools-downloads/client-libraries). \n\n```java\nimport com.google.api.services.mirror.Mirror;\n\nimport java.io.IOException;\n\npublic class MyClass {\n // ...\n\n /**\n * Delete a subscription to a collection.\n * \n * @param service Authorized Mirror service.\n * @param collection Collection to unsubscribe from (supported values are\n * \"timeline\" and \"locations\").\n */\n public static void unsubscribeFromNotifications(Mirror service, String collection) {\n try {\n service.subscriptions().delete(collection).execute();\n } catch (IOException e) {\n System.err.println(\"An error occurred: \" + e);\n }\n }\n\n // ...\n}\n```\n\n### .NET\n\nUses the [.NET client library](/glass/tools-downloads/client-libraries). \n\n```css+lasso\nusing System;\n\nusing Google.Apis.Mirror.v1;\n\npublic class MyClass {\n // ...\n\n /// \u003csummary\u003e\n /// Delete a subscription to a collection.\n /// \u003c/summary\u003e\n /// \u003cparam name='service'\u003eAuthorized Mirror service.\u003c/param\u003e\n /// \u003cparam name='collection'\u003e\n /// Collection to unsubscribe from (supported values are \"timeline\" and\n /// \"locations\").\n /// \u003c/param\u003e\n public static void UnsubscribeFromNotifications(MirrorService service,\n String collection) {\n try {\n service.Subscriptions.Delete(collection).Fetch();\n } catch (Exception e) {\n Console.WriteLine(\"An error occurred: \" + e.Message);\n }\n }\n\n // ...\n}\n```\n\n### PHP\n\nUses the [PHP client library](/glass/tools-downloads/client-libraries). \n\n```php\n/**\n * Delete a subscription to a collection.\n *\n * @param Google_MirrorService $service Authorized Mirror service.\n * @param string $collection Collection to unsubscribe from (supported values\n * are \"timeline\" and \"locations\").\n */\nfunction unsubscribeFromNotifications($service, $collection) {\n try {\n $service-\u003esubscriptions-\u003edelete($collection);\n } catch (Exception $e) {\n print 'An error occurred: ' . $e-\u003egetMessage();\n }\n}\n```\n\n### Python\n\nUses the [Python client library](/glass/tools-downloads/client-libraries). \n\n```python\nfrom apiclient import errors\n# ...\n\ndef unsubscribe_from_notifications(service, collection):\n \"\"\"Delete a subscription to a collection.\n\n Args:\n service: Authorized Mirror service.\n collection: Collection to unsubscribe from (supported values are\n \"timeline\" and \"locations\"\n \"\"\"\n try:\n service.subscriptions().delete(collection).execute()\n except errors.HttpError, error:\n print 'An error occurred: %s' % error\n```\n\n### Ruby\n\nUses the [Ruby client library](/glass/tools-downloads/client-libraries). \n\n```ruby\n##\n# Delete a subscription to a collection.\n#\n# @param [Google::APIClient] client\n# Authorized client instance.\n# @param [String] collection\n# Collection to unsubscribe from (supported values are \"timeline\" and\n# \"locations\").\n# @return nil\ndef unsubscribe_from_notifications(client, collection)\n mirror = client.discovered_api('mirror', 'v1')\n result = client.execute(\n :api_method =\u003e mirror.subscriptions.delete,\n :parameters =\u003e { 'id' =\u003e collection })\n if result.error?\n puts \"An error occurred: #{result.data['error']['message']}\"\n end\nend\n```\n\n### Go\n\nUses the [Go client library](/glass/tools-downloads/client-libraries). \n\n```go\nimport (\n\t\"code.google.com/p/google-api-go-client/mirror/v1\"\n\t\"fmt\"\n)\n\n// UnsubscribeFromNotifications deletes a subscription to a collection.\nfunc UnsubscribeFromNotifications(g *mirror.Service, collection string) error {\n\terr := g.Subscriptions.Delete(collection).Do()\n\tif err != nil {\n\t\tfmt.Printf(\"An error occurred: %v\\n\", err)\n\t\treturn err\n\t}\n\treturn nil\n}\n```\n\n### Raw HTTP\n\nDoes not use a client library. \n\n```http\nDELETE /mirror/v1/subscriptions/timeline HTTP/1.1\nAuthorization: Bearer auth token\n```"]]