CampaignMonitor::getListsByClientId PHP Метод

getListsByClientId() публичный Метод

Returns a list of all subscriber lists for a client.
public getListsByClientId ( string[optional] $clientId = null ) : array
$clientId string[optional]
Результат array
    public function getListsByClientId($clientId = null)
    {
        // set ID
        $clientId = empty($clientId) ? $this->getClientId() : $clientId;
        // make the call
        $records = (array) $this->doCall('clients/' . $clientId . '/lists');
        // stop here if no records were set
        if (empty($records)) {
            return array();
        }
        // reserve variables
        $results = array();
        // loop the records
        foreach ($records as $key => $record) {
            $results[$key]['id'] = $record['ListID'];
            $results[$key]['name'] = $record['Name'];
        }
        // return the records
        return $results;
    }

Usage Example

Пример #1
0
 /**
  * Load the form
  *
  * @return	void
  */
 private function loadForm()
 {
     // create form
     $this->frm = new BackendForm('import');
     // fetch the groups
     $this->externalGroups = $this->cm->getListsByClientId();
     // loop the groups
     foreach ($this->externalGroups as &$group) {
         // add subscribers + count to the group stack
         $group['subscribers'] = BackendMailmotorCMHelper::getSubscribers($group['id']);
         $group['subscribers_amount'] = count($group['subscribers']);
         // get the custom fields
         $customFields = $this->cm->getCustomFields($group['id']);
         // skip this if no custom fields were found
         if (!empty($customFields)) {
             // loop the custom fields
             foreach ($customFields as &$field) {
                 // save only field name in a new format
                 $field = $field['name'];
             }
         }
         // add custom fields to the group stack
         $group['custom_fields'] = empty($customFields) ? null : serialize($customFields);
     }
     // parse the groups
     $this->tpl->assign('groups', $this->externalGroups);
 }