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'); } }
/** * @param string $email * @param array $mergeFields * @param string $listName * @param array $options * * @return array|bool * * @throws \Bonsi\GetResponse\Newsletter\Exceptions\InvalidNewsletterList */ public function subscribe($email, $mergeFields = [], $listName = '', $options = []) { $list = $this->lists->findByName($listName); $defaultOptions = ['email' => $email, 'campaign' => ['campaignId' => $list->getId()]]; $allOptions = array_merge($defaultOptions, $mergeFields); //dd($allOptions); $curlResponse = $this->getResponse->addContact($allOptions); $httpStatus = $this->getResponse->http_status; // if( 202 != $httpStatus ) // { // $this->lastError = $curlResponse; // throw new \Exception("GetResponseAPI3 returned code {$httpStatus}, error: ".print_r($curlResponse,true)); // } // dd(['$httpStatus' => $httpStatus]); // empty stdClass is OK return $curlResponse; // return true; }
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); } } }
} } $getresponse_add = ''; // SEARCH CONTACT if ($getresponse_contact['email'] && $getresponse_contact['name']) { $gr_search_res = $getresponse_api->getContactsByEmail($getresponse_contact['email'], array($list_id), $operator = 'EQUALS'); if ($contactform_obj->cfg['debug']) { echo 'SEARCH RESULTS in (list_id)' . $list_id . "\r\n"; print_r($gr_search_res); echo "\r\n"; } $gr_search_res_arr = (array) $gr_search_res; // ^-- we use a temp variable with the search results casted as an array because $gr_search_res is an object and it is not possible to check if an object is empty (if empty: add, if not: update) // ADD if (!$gr_search_res_arr) { $getresponse_add = $getresponse_api->addContact($list_id, $getresponse_contact['name'], $getresponse_contact['email'], $action = 'standard', $cycle_day = 0, $getresponse_contact['customfields']); if ($contactform_obj->cfg['debug']) { echo 'ADD CONTACT ' . "\r\n"; print_r($getresponse_add); echo "\r\n"; } if (!$getresponse_add) { $admin_api_error[$service_id]['error_message'] = 'Add contact, unknown error.'; } } else { if ($list_v['updateexistingcontact']) { /* $gr_search_res: stdClass Object ( [xyz] => stdClass Object
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); } } }
// 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") { $auth_f = substr($AW_AUTH_CODE, 0, 8) . '_auth.rgen'; if (!file_exists($auth_f)) {
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; } } else { header('Location: http://moustafa.shahum.net/404'); }