/** * Retrieves the lists via GetResponse API and updates the data in DB. * @return string */ function get_getresponse_lists($api_key, $name) { $lists = array(); if (!function_exists('curl_init')) { return __('curl_init is not defined ', 'rapidology'); } if (!class_exists('GetResponse')) { require_once RAD_RAPIDOLOGY_PLUGIN_DIR . 'subscription/getresponse/getresponseapi.class.php'; } $api = new GetResponse($api_key); $campaigns = (array) $api->getCampaigns(); if (!empty($campaigns)) { $error_message = 'success'; foreach ($campaigns as $id => $details) { $lists[$id]['name'] = $details->name; $contacts = (array) $api->getContacts(array($id)); $total_contacts = count($contacts); $lists[$id]['subscribers_count'] = $total_contacts; $lists[$id]['growth_week'] = $this->calculate_growth_rate('getresponse_' . $id); } $this->update_account('getresponse', $name, array('api_key' => esc_html($api_key), 'lists' => $lists, 'is_authorized' => esc_html('true'))); } else { $error_message = __('Invalid API key or something went wrong during Authorization request', 'rapidology'); } return $error_message; }
<?php require_once 'GetResponseAPI.class.php'; $api = new GetResponse('YOUR_API_KEY'); // Connection Testing $ping = $api->ping(); var_dump($ping); // Account $details = $api->getAccountInfo(); var_dump($details); // Campaigns $campaigns = (array) $api->getCampaigns(); $campaignIDs = array_keys($campaigns); $campaign = $api->getCampaignByID($campaignIDs[0]); var_dump($campaigns, $campaign); // Contacts $contacts = (array) $api->getContacts(null); $contactIDs = array_keys($contacts); $setName = $api->setContactName($contactIDs[0], 'John Smith'); $setCustoms = $api->setContactCustoms($contactIDs[0], array('title' => 'Mr', 'middle_name' => 'Fred')); $customs = $api->getContactCustoms($contactIDs[0]); $contact = $api->getContactByID($contactIDs[0]); $geoIP = $api->getContactGeoIP($contactIDs[0]); $opens = $api->getContactOpens($contactIDs[0]); $clicks = $api->getContactClicks($contactIDs[0]); // Find the contact ID by using email ID and delete the contact $contactEmail = (array) $api->getContactsByEmail('EMAIL_ID'); $contactEmailID = array_keys($contactEmail); $deleteResponse = $api->deleteContact($contactEmailID[0]); var_dump($contacts, $setName, $setCustoms, $customs, $contact, $geoIP, $opens, $clicks); // Blacklists
private function setSettings() { if ($this->apikey) { $c = array(); $api = new GetResponse($this->apikey); $this->campaigns = $api->getCampaigns(); $this->active_on_registration = $this->getActiveOnRegistration(); $this->old_webforms = array(); $this->new_webforms = array(); if (!empty($this->campaigns)) { $this->campaign_id = $this->getCampaignId(); foreach ($this->campaigns as $v) { $c[$v->campaignId] = $v->name; } $webforms = $api->getWebforms(); foreach ($webforms as $id => $webform) { if ('enabled' == $webform->status) { $this->old_webforms[$webform->webformId] = $webform->name . ' (' . $c[$webform->campaign->campaignId] . ')'; } } $webforms = $api->getForms(); foreach ($webforms as $id => $webform) { if ('deleted' != $webform->status) { $this->new_webforms[$webform->formId] = $webform->name . ' (' . $c[$webform->campaign->campaignId] . ')'; } } } $this->is_active = $this->isActive(); $this->css_style = $this->getCssStyle(); $this->webform = $this->getWebform($this->apikey); $this->webform_id = $this->webform->webform_id; if ($this->webform) { //for old webforms if ($this->web_form_generation_first == $this->webform->webform_generation) { $webform = $api->getWebform($this->webform->webform_id); } else { $webform = $api->getForm($this->webform->webform_id); } if (!empty($webform->scriptUrl)) { $this->setWebformUrl($webform->scriptUrl); } } } }
function getresponse_getList($api_key) { require_once 'GetResponseAPI.class.php'; try { $api = new GetResponse($api_key); $campaigns = (array) $api->getCampaigns(); return $campaigns; } catch (Exception $e) { return null; } return null; }