Skip to content

Instantly share code, notes, and snippets.

@alesanabriav
Created August 18, 2017 21:50
Show Gist options
  • Save alesanabriav/a36ace484ab3ab62693905c9d958f909 to your computer and use it in GitHub Desktop.
Save alesanabriav/a36ace484ab3ab62693905c9d958f909 to your computer and use it in GitHub Desktop.
function cl_create_person($appId, $apiKey, $data, $endpoint = 'https://api.convertloop.co/v1/people') {
try {
if(empty($data['pid'])) {
$data['pid'] = isset($_COOKIE['dp_pid']) ? $_COOKIE['dp_pid'] : '';
}
// $data: { "email": "alejandro@acn.com", "pid": "", "add_tags": ["ENGLISH"] }
$data = json_encode($data);
$auth_string = $appId . ":" . $apiKey;
$auth = base64_encode($auth_string);
$headers = array(
"Authorization" => "Basic " . $auth,
'Accept' => 'application/json',
'content-type' => 'application/json'
);
$req = Requests::post($endpoint, $headers, $data);
return $req->body;
} catch(Exception $e) {
return ['error' => $e];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment