Tips and Tricks HQ Support Portal › Forums › WP eMember › eMember – how to set the variables to pass the data to getresponse
- This topic has 3 replies, 3 voices, and was last updated 6 years, 11 months ago by
admin.
-
AuthorPosts
-
March 28, 2018 at 8:59 am #14801
GarSEO
MemberI am trying to solve something within the eMember_auto_responder_handler.php
That ist the eMember_getResponse_subscribe” function
# 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’
)
so far so good…
but I need to pass the username, the password and a custom field called “NexusGlobal_SponsorID”
to GetResponse too. I did set custom fields within GetResponse but I really donĀ“t know how to set and pass the variables correctly.
‘username’ => $user_name,
‘sponsorid’ => $wp_emember_NexusGlobal_SponsorID,
‘passwort’ => $wp_emember_pwd,
I am getting the error: “syntax error, unexpected ”username” (T_CONSTANT_ENCAPSED_STRING), expecting ‘)'”
help please
March 28, 2018 at 12:05 pm #77601wzp
ModeratorA “syntax error” most likely means you stuck your new code in “the wrong place.” Please post the entire code segment for that function, you modified.
P.S. What’s a “passwort”
March 28, 2018 at 1:39 pm #77602GarSEO
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;
}
March 29, 2018 at 7:09 am #77603admin
KeymasterA common cause for this is webhosts using older version of PHP. So you should ask them which PHP version is used on your site.
Also, make sure you are adding the closing bracket to to match with the opening ones.
This falls under custom coding. So it will need to be handled using the following:
-
AuthorPosts
- You must be logged in to reply to this topic.