$key = "miapikey";
$headers = [
'content-type' => 'application/json',
'Api-Token' => $key,
"Cache-Control" => "no-cache",
];
$client = new Client();
$body = [
'contact' => [
"email" => $request->input('email'),
"firstName" => "",
"phone" => "",
"tags" => 'api',
],
];
De este modo creo un contacto, incluso a la vez lo puedo modificar para añadirlo a una lista:
$response = $client->request('POST', 'https://url.api-us1.com/api/3/contacts', [
'headers' => $headers,
'json' => $body,
]);
Arriba creo el contacto, incluso a la vez lo puedo modificar para añadirlo a una lista:
if($response->getStatusCode() == "200" || $response->getStatusCode() == "201"){
$arrResponse = json_decode($response->getBody(),true);
foreach($arrResponse as $arr){
//Log::debug($arr['id']);
$body = [
'contactList' => [
"contact" => $arr['id'],
"list" => 3,
"status" => 1
]
];
$response = $client->request('POST', 'https://url.api-us1.com/api/3/contactLists', [
'headers' => $headers,
'json' => $body,
]);
}
}