From 68ac76197a647296fbf42c1311b06f896327a56b Mon Sep 17 00:00:00 2001 From: Carl Sutherland Date: Thu, 26 Feb 2015 15:30:16 -0500 Subject: [PATCH] Add AudienceUpdate endpoint. * add handling for PUT requests * add AudienceUpdate method. --- MadMimi.class.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/MadMimi.class.php b/MadMimi.class.php index 0cc48b4..6a88149 100644 --- a/MadMimi.class.php +++ b/MadMimi.class.php @@ -67,13 +67,17 @@ function DoRequest($path, $options, $return_status = false, $method = 'GET') { case 'GET': break; case 'POST': + case 'PUT': curl_setopt($ch, CURLOPT_POST, TRUE); curl_setopt($ch, CURLOPT_POSTFIELDS, $request_options); break; } + if ($method == 'PUT') { + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT'); + } if ($this->debug == true) { echo "URL: {$url}
"; - if ($method == 'POST') { + if ($method == 'POST' || $method == 'PUT') { echo "Request Options: {$request_options}"; } } else { @@ -243,4 +247,10 @@ function RemoveMembership($list_name, $email, $return = false) { $request = $this->DoRequest($path, $options, $return, 'POST'); return $request; } + function AudienceUpdate($email, $additional = array(), $return = false) { + $path = str_replace('%email%', rawurlencode($email), '/audience_members/%email%'); + $options = array( 'audience_member' => $additional ) + $this->default_options(); + $request = $this->DoRequest($path, $options, $return, 'PUT'); + return $request; + } }