Skip to content

Commit

Permalink
trackUnsubscribe use POST
Browse files Browse the repository at this point in the history
  • Loading branch information
twisted1919 committed Jan 25, 2018
1 parent db3aa6a commit 8354e54
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
21 changes: 11 additions & 10 deletions MailWizzApi/Endpoint/CampaignsTracking.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ class MailWizzApi_Endpoint_CampaignsTracking extends MailWizzApi_Base
public function trackUrl($campaignUid, $subscriberUid, $hash)
{
$client = new MailWizzApi_Http_Client(array(
'method' => MailWizzApi_Http_Client::METHOD_GET,
'url' => $this->config->getApiUrl(sprintf('campaigns/%s/track-url/%s/%s', (string)$campaignUid, (string)$subscriberUid, (string)$hash)),
'paramsGet' => array(),
'method' => MailWizzApi_Http_Client::METHOD_GET,
'url' => $this->config->getApiUrl(sprintf('campaigns/%s/track-url/%s/%s', (string)$campaignUid, (string)$subscriberUid, (string)$hash)),
'paramsGet' => array(),
));

return $response = $client->request();
Expand All @@ -47,9 +47,9 @@ public function trackUrl($campaignUid, $subscriberUid, $hash)
public function trackOpening($campaignUid, $subscriberUid)
{
$client = new MailWizzApi_Http_Client(array(
'method' => MailWizzApi_Http_Client::METHOD_GET,
'url' => $this->config->getApiUrl(sprintf('campaigns/%s/track-opening/%s', (string)$campaignUid, (string)$subscriberUid)),
'paramsGet' => array(),
'method' => MailWizzApi_Http_Client::METHOD_GET,
'url' => $this->config->getApiUrl(sprintf('campaigns/%s/track-opening/%s', (string)$campaignUid, (string)$subscriberUid)),
'paramsGet' => array(),
));

return $response = $client->request();
Expand All @@ -60,14 +60,15 @@ public function trackOpening($campaignUid, $subscriberUid)
*
* @param string $campaignUid
* @param string $subscriberUid
* @param array $data
* @return MailWizzApi_Http_Response
*/
public function trackUnsubscribe($campaignUid, $subscriberUid)
public function trackUnsubscribe($campaignUid, $subscriberUid, array $data = array())
{
$client = new MailWizzApi_Http_Client(array(
'method' => MailWizzApi_Http_Client::METHOD_GET,
'url' => $this->config->getApiUrl(sprintf('campaigns/%s/track-unsubscribe/%s', (string)$campaignUid, (string)$subscriberUid)),
'paramsGet' => array(),
'method' => MailWizzApi_Http_Client::METHOD_POST,
'url' => $this->config->getApiUrl(sprintf('campaigns/%s/track-unsubscribe/%s', (string)$campaignUid, (string)$subscriberUid)),
'paramsPost' => $data,
));

return $response = $client->request();
Expand Down
6 changes: 5 additions & 1 deletion examples/campaigns_tracking.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@
/*===================================================================================*/

// Track subscriber unsubscribe for campaign
$response = $endpoint->trackUnsubscribe('CAMPAIGN-UNIQUE-ID', 'SUBSCRIBER-UNIQUE-ID');
$response = $endpoint->trackUnsubscribe('CAMPAIGN-UNIQUE-ID', 'SUBSCRIBER-UNIQUE-ID', array(
'ip_address' => '123.123.123.123',
'user_agent' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36',
'reason' => 'Reason for unsubscribe!',
));

// DISPLAY RESPONSE
echo '<hr /><pre>';
Expand Down

0 comments on commit 8354e54

Please sign in to comment.