Created
August 18, 2017 21:50
-
-
Save alesanabriav/a36ace484ab3ab62693905c9d958f909 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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