Forum Replies Created
-
AuthorPosts
-
March 28, 2018 at 1:39 pm in reply to: eMember – how to set the variables to pass the data to getresponse #77602
GarSEO
MemberThat is the entire code section for the eMember_getResponse_subscribe” function:
passwort is the german word for password
function eMember_getResponse_subscribe($campaign_name, $fname, $lname, $email_to_subscribe, $user_name, $wp_emember_NexusGlobal_SponsorID, $wp_emember_pwd) {
eMember_log_debug(‘Attempting to call GetResponse API for list signup…’, true);
$emember_config = Emember_Config::getInstance();
$api_key = $emember_config->getValue(‘eMember_getResponse_api_key’);
// API 2.x URL
$api_url = ‘http://api2.getresponse.com’;
$customer_name = $fname . ” ” . $lname;
eMember_log_debug(‘API Key:’ . $api_key . ‘, Customer name:’ . $customer_name, true);
// initialize JSON-RPC client
include_once(‘lib/auto-responder/eMember_jsonRPCClient.php’);
$client = new eMember_jsonRPCClient($api_url);
$result = NULL;
eMember_log_debug(‘Attempting to retrieve campaigns for ‘ . $campaign_name, true);
if (empty($campaign_name)) {
eMember_log_debug(‘Getresponse campaign name is empty. This signup request will be ignored.’, true);
return;
}
$result = $client->get_campaigns(
$api_key, array(
# find by name literally
‘name’ => array(‘EQUALS’ => $campaign_name)
)
);
# uncomment this line to preview data structure
# print_r($result);
# since there can be only one campaign of this name
# first key is the CAMPAIGN_ID you need
$CAMPAIGN_ID = array_pop(array_keys($result));
eMember_log_debug(“Attempting GetResponse add contact operation for campaign ID: ” . $CAMPAIGN_ID . ” Name: ” . $customer_name . ” Email: ” . $email_to_subscribe . ” username_gut: ” . $user_name . ” sponsorid_ng: ” . $wp_emember_NexusGlobal_SponsorID . ” passwort_gut: ” . $wp_emember_pwd, true);
if (empty($CAMPAIGN_ID)) {
eMember_log_debug(“Could not retrieve campaign ID. Please double check your GetResponse Campaign Name:” . $campaign_name, false);
} else {
# add contact to the specified campaign
try {
$result = $client->add_contact(
$api_key, array(
‘campaign’ => $CAMPAIGN_ID,
‘name’ => $customer_name,
’email’ => $email_to_subscribe,
‘cycle_day’ => ‘0’,
‘username_gut’ => $user_name,
‘sponsorid_ng’ => $wp_emember_NexusGlobal_SponsorID,
‘passwort_gut’ => $wp_emember_pwd,
)
);
} catch (Exception $e) {
//eMember_log_debug_array($e,false);//Show this to see the details of the exception and failure
eMember_log_debug(“Getresponse add_contact operation failed for email: ” . $email_to_subscribe, false);
return false;
}
}
# uncomment this line to preview data structure
print_r($result);
eMember_log_debug(“GetResponse contact added… result:” . $result, true);
return true;
}
-
AuthorPosts