diff --git a/RESTAPIphpListClient.php b/RESTAPIphpListClient.php
index 8e035f8..be90ecb 100644
--- a/RESTAPIphpListClient.php
+++ b/RESTAPIphpListClient.php
@@ -1,6 +1,6 @@
getBody()) {
$obj = json_decode($response->getBody(), true);
@@ -35,6 +34,7 @@
//Use session key as password for basic auth
$credentials = base64_encode($loginname . ':' . $key);
+// Get list info where id=1
$listInfo = $client->get($base_uri . '/lists/1',
[
'headers' => [
@@ -46,6 +46,7 @@
if ($listInfo->getBody()) {
$listInfoResponse = json_decode($listInfo->getBody(), true);
+
echo 'List Info:
';
foreach ($listInfoResponse as $key => $value) {
@@ -55,6 +56,7 @@
echo '
';
}
+//Get all subscribers where list id=1
$members = $client->get($base_uri . '/lists/1/members',
[
'headers' => [
@@ -76,3 +78,24 @@
echo '
';
}
}
+
+// Add a new subscriber
+try {
+ $subscriberRequest = $client->request('POST', $base_uri . '/subscribers',
+ [
+ 'headers' => [
+ 'Authorization' => 'Basic ' . $credentials,
+ 'Content-Type' => 'application/json',
+ ],
+ 'json' => [
+ 'email' => 'restapi@example.com',
+ 'confirmed' => true,
+ 'blacklisted' => false,
+ 'html_email' => true,
+ 'disabled' => false,
+ ],
+ ]
+ );
+} catch (\GuzzleHttp\Exception\GuzzleException $e) {
+}
+$subscriberRequest->getBody();