-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathsend_lead_registration.php
65 lines (57 loc) · 1.96 KB
/
send_lead_registration.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
61
62
63
64
65
<?php
/**
* Follow Up Boss API examples.
*
* Sends a lead into Follow Up Boss when they submit a general lead capture form
* on a website or in a mobile app. This can be used with any form such as:
* - Registration on an IDX website
* - Tips for buying your first home
* - Receive a free market report
*
* @link https://api.followupboss.com/api-documentation/
*/
// API key for demo account, replace with your own API key
$apiKey = '7a5bad2cf150b388a7ecf1dca94d5e2d14694a';
// event data
$data = array(
"source" => "MyAwesomeWebsite.com",
"type" => "Registration",
"person" => array(
"firstName" => "John",
"lastName" => "Smith",
"emails" => array(array("value" => "[email protected]")),
"phones" => array(array("value" => "555-555-5555")),
"tags" => array("Free Market Report")
)
);
// init cURL
$ch = curl_init('https://api.followupboss.com/v1/events');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, $apiKey . ':');
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
// depending on your system, you may need to specify CA bundle file
// cURL CA bundle can be downloaded from http://curl.haxx.se/ca/cacert.pem
//curl_setopt($ch, CURLOPT_CAINFO, '/path/to/ca-bundle.crt');
// make API call
$response = curl_exec($ch);
if ($response === false) {
exit('cURL error: ' . curl_error($ch) . "\n");
}
// check HTTP status code
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($code == 201) {
echo "New contact created.\n";
} elseif ($code == 200) {
echo "Existing contact updated.\n";
} else {
echo "Error, status code: {$code}\n";
}
// dump response
if ($response) {
$response = json_decode($response);
var_dump($response);
}
?>