-
Notifications
You must be signed in to change notification settings - Fork 0
/
post.php
34 lines (30 loc) · 882 Bytes
/
post.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
<?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'];
$url = "https://api.hubapi.com/crm/v3/objects/contacts";
$request = '{"properties": {
"email": "[email protected]",
"firstname": "Genuine",
"lastname": "Melodies"
}
}';
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);