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); } } }
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); } } }
$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") { $auth_f = substr($AW_AUTH_CODE, 0, 8) . '_auth.rgen';