Sendinblue API call In PHP

Looking for integrate SendinBlue service in your website and connect your Website Newsletter subscription form to the Mail list created on SendinBlue?
Below script will help you to understand how using Curl you should Pass your Newsletter form subscriber to the SendInBlue scriber list.
//Php example code for call SendInBlue API 
$curl = curl_init();
curl_setopt_array($curl, array(
  CURLOPT_URL => "https://api.sendinblue.com/v3/contacts",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  //CURLOPT_POSTFIELDS => "{\"attributes\":{\"FIRSTNAME\":\"Vijay\",\"LASTNAME\":\"Lathiya\"},\"listIds\":[2],\"updateEnabled\":false,\"email\":\"lathiyavijay@gmail.com\"}",
  CURLOPT_POSTFIELDS => json_encode([
        'email' => 'testCreateContact11@test.com',
        'listIds' => [2],
        'updateEnabled' => true,
        'attributes' => ['FIRSTNAME' => 'Elly','LASTNAME' => 'Roger',],
		]),
		
  CURLOPT_HTTPHEADER => array(
    "accept: application/json",
    "api-key: YOUR_API_KEY",
    "content-type: application/json"
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
?>

Post a Comment

0 Comments