-
Notifications
You must be signed in to change notification settings - Fork 0
/
deleteproperty.php
40 lines (37 loc) · 1.14 KB
/
deleteproperty.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
//load .env file
require_once realpath(__DIR__ . "/vendor/autoload.php");
use Dotenv\Dotenv;
$dotenv = Dotenv::createImmutable(__DIR__);
$dotenv->load();
$curl = curl_init();
$token = $_ENV['API_KEY'];
$propertyName = "contact_height";
$objectType = "contacts";
$request = $propertyName.$objectType;
$url = "https://api.hubapi.com/crm/v3/properties/${objectType}/${propertyName}";
curl_setopt ($curl,CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "DELETE");
curl_setopt($curl,CURLOPT_HTTPHEADER,["authorization: Bearer $token",
"content-type: application/json"]);
curl_setopt ($curl,CURLOPT_POSTFIELDS, $request);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec ($curl);
$error = curl_error($curl);
if($error){
echo $e;
}
else{
print_r($result);
echo "Deleted Successfully";
}
curl_close($curl);
// else{
// $httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
// // Check the HTTP Status code
// switch ($httpCode) {
// case 404:
// $error_status = "404: API Not found";
// break;
// }
// }