public function free_report_signup() { $this->form_validation->set_rules('first_name', 'Name', 'trim|min_length[2]|max+length[15]|xss_clean'); $this->form_validation->set_rules('email', 'Email Address', 'trim|required|valid_email|is_unique[users.email]'); if ($this->form_validation->run() == FALSE) { $this->view_data['errors'] = validation_errors(); $this->session->set_flashdata('errors', $this->view_data['errors']); redirect(''); } else { $this->load->model('InvestmentModel'); $post = $this->input->post(); $model = $post; $add_email = $this->InvestmentModel->add_user($model); if ($add_email == FALSE) { $this->session->set_flashdata['errors'] = 'There was a system error, please try again.'; redirect(''); } // If successful send new customer to GetResponse API $this->load->library('GetResponse'); $api = new GetResponse('929e79b37d3acd438f49957aab51521b'); // Testing Account $addContact = $api->addContact('pDm5M', $post['first_name'], $post['email']); // Optional message $message = "Success!"; $this->session->set_flashdata('message', $message); redirect('free_report'); } }
/** * 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; }
public function onUserAfterSave($user, $isnew, $success, $msg) { if (!$isnew && $this->isActive() && $this->getCampaignId()) { return true; } require_once JPATH_ADMINISTRATOR . '/components/com_getresponse/assets/lib/getresponse-api.class.php'; $api = new GetResponse($this->apikey); $api->addContact(array('name' => $user['name'], 'email' => $user['email'], 'dayOfCycle' => 0, 'campaign' => array('campaignId' => $this->getCampaignId()))); return true; }
function sendGetResponse($mailSubscribe) { if (defined('GR_APIKEY') && defined('GR_CAMPAIGN')) { $api = new GetResponse(GR_APIKEY); $campaign = $api->getCampaignByName(GR_CAMPAIGN); $subscribe = $api->addContact($campaign, getName($mailSubscribe), $mailSubscribe); if (array_key_exists('duplicated', $subscribe)) { throw new Exception("Email exist", 2); } } }
<?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); } } } }
$admin_api_error['constantcontact']['error_message'] = implode("\r\n", $service_requirements_status['errors']); } // if/else service status debugServiceSeparator($service_id, false); } // CONSTANTCONTACT /************************************************************************************** * GETRESPONSE API **************************************************************************************/ if (!empty($cfg['getresponse']['apikey']) && !empty($cfg['getresponse']['lists'])) { $service_id = 'getresponse'; debugServiceSeparator($service_id, true); $service_requirements_status = $cfgenwpapi_obj->checkServiceRequirements($service_id); if ($service_requirements_status['status']) { require '../api/getresponse/GetResponseAPI.class.php'; $getresponse_api = new GetResponse($cfg[$service_id]['apikey']); $getresponse_ping = $getresponse_api->ping(); if ($getresponse_ping == 'pong') { foreach ($cfg[$service_id]['lists'] as $list_v) { $list_id = $list_v['list_id']; $getresponse_contact = array(); $getresponse_contact['email'] = ''; $getresponse_contact['name'] = ''; $getresponse_contact['customfields'] = array(); // FIELDS if (!empty($list_v['fields'])) { foreach ($list_v['fields'] as $field_v) { if ($field_v['list_field_id'] == 'email' || $field_v['list_field_id'] == 'name') { // 'name' IS a mandatory field $getresponse_contact[$field_v['list_field_id']] = getElementValue($field_v['element_id']); }
/** * Checks validity of GetResponse API key and initializes API if valid. * * @return bool|null */ public function initialize_api() { if (!is_null($this->api)) { return true; } /* Load the GetResponse API library. Class has been modified to make some functions public. */ if (!class_exists('GetResponse')) { require_once 'api/GetResponseAPI.class.php'; } /* Get the plugin settings */ $settings = $this->get_plugin_settings(); /* If the API key is empty, return null. */ if (rgblank($settings['api_key'])) { return null; } $this->log_debug(__METHOD__ . "(): Validating login for API Info for key {$settings['api_key']}."); $getresponse = new GetResponse($settings['api_key']); /* Run authentication test request. */ if ($getresponse->ping() == 'pong') { /* Log that test passed. */ $this->log_debug(__METHOD__ . '(): API Key is valid.'); /* Assign GetResponse object to the class. */ $this->api = $getresponse; return true; } else { $this->log_error(__METHOD__ . '(): Invalid API Key.'); return false; } }
function getresponse_addContact($info, $campaign, $api_key) { require_once 'GetResponseAPI.class.php'; try { $api = new GetResponse($api_key); $contact = $api->addContact($campaign, $info['name'], $info['email']); if ($contact) { return true; } } catch (Exception $e) { return false; } return false; }
function sendGetResponse($mailSubscribe, $merge_vars = NULL) { if (defined('GR_APIKEY') && defined('GR_CAMPAIGN')) { $api = new GetResponse(GR_APIKEY); $campaign = $api->getCampaignByName(GR_CAMPAIGN); $subscribe = $api->addContact($campaign, getName($mailSubscribe), $mailSubscribe, 'standard', 0, $merge_vars); //$firas = $api->getContacts($campaign); //$firas = json_decode($subscribe, true); // $output = json_encode(array('type'=>'error', 'text' => 'err: '. serialize($subscribe) )); // die($output); //if(array_key_exists('duplicated', $subscribe)){ if ($subscribe) { $output = json_encode(array('type' => 'message', 'text' => 'Thank you for your Subscription.')); die($output); } else { $output = json_encode(array('type' => 'error', 'text' => 'Error: Email Already Exists')); die($output); } } }
$cm = new CampaignMonitor($api_key, null, null, $list_id); $result = $cm->subscriberAdd($email, $firstname); // SUCCESS SENDING if ($result['Result']['Code'] == 0) { echo json_encode(array("status" => "success")); // ERROR SENDING } else { /*echo json_encode(array( "status" => "error", "type" => $result['Result']['Message'] ));*/ echo json_encode(array("status" => "error", "type" => "Looks like something went wrong. Please try again later.")); errorlog("campaignmonitor", "Error : " . $result['Result']['Code'] . " : " . $result['Result']['Message']); } } elseif ($STORE_MODE == "getresponse") { $gr = new GetResponse($GR_API_KEY); $campaign = $gr->getCampaignByName($GR_CAMPAIGN_NAME); $result = $gr->addContact($campaign, $firstname, $email, 'standard', 0, array()); // SUCCESS SENDING if (isset($result->queued) && $result->queued == 1) { echo json_encode(array("status" => "success")); // ERROR SENDING } else { /*echo json_encode(array( "status" => "error", "type" => $result->message ));*/ echo json_encode(array("status" => "error", "type" => "Looks like something went wrong. Please try again later.")); errorlog("getresponse", $result->message); } } elseif ($STORE_MODE == "aweber") {
<?php if ($_SERVER['REQUEST_METHOD'] == 'POST') { require_once 'GetResponseAPI.class.php'; $api = new GetResponse('b48303725f37bd770a2a1c74963dd7ba'); if (isset($_POST['name'])) { $name = $_POST['name']; } if (isset($_POST['mail'])) { $email = $_POST['mail']; } if (empty($name) || empty($email)) { echo 'Invalid params'; die; } // Campaigns $campaigns = (array) $api->getCampaigns(); $campaignIDs = array_keys($campaigns); foreach ($campaigns as $k => $v) { $firstCompaignTokenAsId = $k; } $campaign = $api->getCampaignByID($campaignIDs[0]); $res = $api->addContact($firstCompaignTokenAsId, $name, $email, 'insert'); //var_dump($res); if (isset($res->code)) { $out = $res->code; echo $out; } else { $out = $res->queued; echo $out; }
/** * @param string $email * * @return string */ protected function getSubscriberHash($email) { return $this->getResponse->subscriberHash($email); }