Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions examples.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
var_dump($oiContact->addList('somelist', 1698, true, false, false, 'Just an example list', 'Some List'));
// Subscribe contact to list
var_dump($oiContact->subscribeContactToList(42094396, 179962, 'normal'));
// Move contact to another list
var_dump($oiContact->moveSubscriptionToList("179962_42094396", 179963, 'normal'));
// Grab all campaigns
var_dump($oiContact->getCampaigns());
// Create message
Expand Down
28 changes: 27 additions & 1 deletion lib/iContactApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,9 @@ public function makeCall($sResource, $sMethod = 'GET', $mPostData = null, $sRetu
} elseif (!is_string($mPostData) || !file_exists($mPostData)) {
// Not a file, so we assume this is just data
curl_setopt($rHandle, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($rHandle, CURLOPT_POSTFIELDS, $mPostData);
curl_setopt($rHandle, CURLOPT_POSTFIELDS, json_encode($mPostData));
// Set the request JSON
$this->sLastRequest = (string) json_encode($mPostData);
} else {
$rFileContentHandle = fopen($mPostData, 'r');
if ($rFileContentHandle === false) {
Expand Down Expand Up @@ -528,6 +530,30 @@ public function subscribeContactToList($iContactId, $iListId, $sStatus = 'normal
return $aSubscriptions;
}

/**
* This method moves a contact to another list
* @access public
* @param string $sSubscriptionId
* @param integer $iListId
* @param string $sStatus
* @return object
**/
public function moveSubscriptionToList($sSubscriptionId, $iListId, $sStatus = 'normal') {
// Valid statuses
$aValidStatuses = array('normal', 'pending', 'unsubscribed');
// Check for a valid status
if (!empty($sStatus) && !in_array($sStatus, $aValidStatuses)) {
$sStatus = 'normal';
}
// Setup the subscription and make the call
$aSubscription = $this->makeCall("/a/{$this->setAccountId()}/c/{$this->setClientFolderId()}/subscriptions/{$sSubscriptionId}", 'PUT', array(
'listId' => $iListId,
'status' => $sStatus
), 'subscription');
// Return the subscription
return $aSubscription;
}

/**
* This method updates a contact in your iContact account
* @access public
Expand Down