-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpatchproperty.php
More file actions
33 lines (31 loc) · 915 Bytes
/
patchproperty.php
File metadata and controls
33 lines (31 loc) · 915 Bytes
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
<?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";
$url = "https://api.hubapi.com/crm/v3/properties/${objectType}/${propertyName}";
$request = '{
"label": "My Contact Property",
"type": "string",
"fieldType": "text"
}';
curl_setopt ($curl,CURLOPT_URL, $url);
curl_setopt($curl,CURLOPT_CUSTOMREQUEST,'PATCH');
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);
}
curl_close($curl);