Chilkat Online Tools

phpAx / Support API / Bulk Unregister Push Notification Devices

Back to Collection Items

<?php

// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.

$http = new COM("Chilkat_9_5_0.Http");

$http->BasicAuth = 1;
$http->Login = 'login';
$http->Password = 'password';

// Use this online tool to generate code from sample JSON: Generate Code to Create JSON

// The following JSON is sent in the request body.

// {}

$json = new COM("Chilkat_9_5_0.JsonObject");

$http->SetRequestHeader('Content-Type','application/json');
$http->SetRequestHeader('Accept','application/json');

// resp is a Chilkat_9_5_0.HttpResponse
$resp = $http->PostJson3('https://example.zendesk.com/api/v2/push_notification_devices/destroy_many','application/json',$json);
if ($http->LastMethodSuccess == 0) {
    print $http->LastErrorText . "\n";
    exit;
}

$sbResponseBody = new COM("Chilkat_9_5_0.StringBuilder");
$resp->GetBodySb($sbResponseBody);

$jResp = new COM("Chilkat_9_5_0.JsonObject");
$jResp->LoadSb($sbResponseBody);
$jResp->EmitCompact = 0;

print 'Response Body:' . "\n";
print $jResp->emit() . "\n";

$respStatusCode = $resp->StatusCode;
print 'Response Status Code = ' . $respStatusCode . "\n";
if ($respStatusCode >= 400) {
    print 'Response Header:' . "\n";
    print $resp->Header . "\n";
    print 'Failed.' . "\n";

    exit;
}


?>

Curl Command

curl  -u login:password -X POST
	-H "Content-Type: application/json"
	-H "Accept: application/json"
	-d '{}'
https://example.zendesk.com/api/v2/push_notification_devices/destroy_many

Postman Collection Item JSON

{
  "name": "Bulk Unregister Push Notification Devices",
  "request": {
    "method": "POST",
    "header": [
      {
        "key": "Content-Type",
        "value": "application/json"
      },
      {
        "key": "Accept",
        "value": "application/json"
      }
    ],
    "body": {
      "mode": "raw",
      "raw": "{}",
      "options": {
        "raw": {
          "headerFamily": "json",
          "language": "json"
        }
      }
    },
    "url": {
      "raw": "{{baseUrl}}/api/v2/push_notification_devices/destroy_many",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "api",
        "v2",
        "push_notification_devices",
        "destroy_many"
      ]
    },
    "description": "Unregisters the mobile devices that are receiving push notifications. Specify the devices as an array of mobile device tokens.\n\n#### Allowed for\n\n* Admins"
  },
  "response": [
    {
      "name": "Successful response",
      "originalRequest": {
        "method": "POST",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          },
          {
            "description": "Added as a part of security scheme: basic",
            "key": "Authorization",
            "value": "Basic <credentials>"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{}",
          "options": {
            "raw": {
              "headerFamily": "json",
              "language": "json"
            }
          }
        },
        "url": {
          "raw": "{{baseUrl}}/api/v2/push_notification_devices/destroy_many",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v2",
            "push_notification_devices",
            "destroy_many"
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "<string>"
    }
  ]
}