-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathput.php
29 lines (26 loc) · 835 Bytes
/
put.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
<?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'];
$id = 201;
$url = "https://api.hubapi.com/crm/v3/objects/contacts/$id";
$requestArray = ["id"=>201,"email"=>"rony@hk.com", "firstname"=> "Rony", "lastname"=> "Andrews"];
curl_setopt ($curl,CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($requestArray));
curl_setopt($curl,CURLOPT_HTTPHEADER,["authorization: Bearer $token",
"content-type: application/json"]);
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);