Sample code for 30+ languages & platforms
PHP

GetHarvest - Delete Contact

See more GetHarvest Examples

Delete a contact. Returns a 200 OK response code if the call succeeded.

Chilkat PHP Downloads

PHP
<?php

use Chilkat2\Http;
use Chilkat2\HttpResponse;

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

$http = new Http();

// Implements the following CURL command:

// curl "https://api.harvestapp.com/v2/contacts/CONTACT_ID" \
//   -H "Authorization: Bearer ACCESS_TOKEN" \
//   -H "Harvest-Account-Id: ACCOUNT_ID" \
//   -H "User-Agent: MyApp (yourname@example.com)" \
//   -X DELETE

$http->SetRequestHeader('User-Agent', 'MyApp (yourname@example.com)');
$http->SetRequestHeader('Authorization', 'Bearer ACCESS_TOKEN');
$http->SetRequestHeader('Harvest-Account-Id', 'ACCOUNT_ID');

$resp = new HttpResponse();
try {
    $http->HttpNoBody('DELETE', 'https://api.harvestapp.com/v2/contacts/CONTACT_ID', $resp);
} catch (\Chilkat2\Exception $e) {
    echo $e->getMessage(), "\n";
    exit;
}

$respStatusCode = $resp->StatusCode;
echo 'Response Status Code = ', $respStatusCode, "\n";
if ($respStatusCode != 200) {
    echo "Response Header:\n";
    echo $resp->Header, "\n";
    echo "Response Body:\n";
    echo $resp->BodyStr, "\n";
    echo "Failed.\n";
    exit;
}

echo "Success.\n";