-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetbyemail.php
60 lines (55 loc) · 2.41 KB
/
getbyemail.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?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'];
$mail_contact = "hillary@hk.com";
$url = "https://api.hubapi.com/crm/v3/objects/contacts/${mail_contact}?idProperty=email&properties=email,is_tech,favorite_contact,firstname,lastname";
curl_setopt ($curl, CURLOPT_URL, $url);
curl_setopt($curl,
CURLOPT_HTTPHEADER,["authorization: Bearer $token",
"content-type: application/json"]
);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec ($curl);
curl_close($curl);
$decs = json_decode($result,true);
// print_r($decs);
if($e = curl_error($curl)){
echo $e;
}
else{
// echo "<pre>";
// print_r($result);
$decs = json_decode($result,true);
echo "<pre>";
// print_r($decs);
print_r("Id :" .$decs['id']."</br>");
print_r("Email :" .$decs['properties']['email']."</br>");
print_r("Is tech :" .$decs['properties']['is_tech']."</br>");
print_r("Favorite contact :" .$decs['properties']['favorite_contact']."</br>");
print_r("Last name is :" .$decs['properties']['firstname']."</br>");
print_r("Last name is :" . $decs['properties']['lastname']."</br>");
print_r($decs['createdAt']."</br>");
echo "<hr/>";
// foreach($decs as $dec):
// {
//print_r($dec);
// foreach($dec as $next):
// {
// print_r($next['id']);
// print_r($next['properties']['email']."</br>");
// print_r("Is tech :" .$next['properties']['is_tech']."</br>");
// print_r("Favorite contact :" .$next['properties']['favorite_contact']."</br>");
// print_r("Last name is :" .$next['properties']['firstname']."</br>");
// print_r("Last name is :" . $next['properties']['lastname']."</br>");
// print_r($next['createdAt']."</br>");
// echo "<hr/>";
// }
// endforeach;
// }
// endforeach;
}