-
Notifications
You must be signed in to change notification settings - Fork 0
/
postproperty.php
36 lines (33 loc) · 973 Bytes
/
postproperty.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
<?php
use Dotenv\Dotenv;
//load .env file
require_once (__DIR__ . "/vendor/autoload.php");
$dotenv = Dotenv::createImmutable(__DIR__);
$dotenv->load();
$curl = curl_init();
$token = $_ENV['API_KEY'];
$objectType = "contacts";
$url = "https://api.hubapi.com/crm/v3/properties/${objectType}";
$request = '{
"name": "contact_height",
"label": "My Contact Property",
"type": "number",
"fieldType": "number",
"groupName": "contactinformation"
}
}';
curl_setopt ($curl,CURLOPT_URL, $url);
curl_setopt ($curl,CURLOPT_POST, true);
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);