Contact list resource PHP code samples#
Here are some PHP code samples for the contact list resource.
Edit an existing contact list#
Open an existing contact list resource, authenticate and subscribe two new contacts:
<?php
$data = array(
'contacts' => array(
'test1@example.org', 'test2@example.org'
),
'action' => 'subscribe'
);
$jsondata = json_encode($data);
$ch = curl_init ('https://api.sendmachine.com/list/{list_hash}');
curl_setopt($ch, CURLOPT_USERPWD, 'user:pass');
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsondata);
$response = curl_exec($ch);