Question

Im trying to take data from Contact Form 7 WordPress plugin and pass it with json to GetResponse API

I have a php file that pull the data and send it, and its looks like this I'm getting the CF7 email of confirmation but im not getting GetResponse Email confirmation for newsletter, i don't understand why, i tried to do some debugging and there was no errors

add_action('wpcf7_before_send_mail', 'mytheme_save_to_getresponse', 10, 1);
function mytheme_save_to_getresponse($form)
{
include 'ChromePhp.php';

    require_once 'jsonRPCClient.php';
    $api_key = 'some_api_key';
    $api_url = 'http://api2.getresponse.com';
    $client = new jsonRPCClient($api_url);
    $result = NULL;

try {
    $result = $client->get_campaigns(
        $api_key,
        array (
            # find by name literally
            'name' => array ( 'EQUALS' => 'testcase_001' )
        )
    );
}
catch (Exception $e) {
    # check for communication and response errors
    # implement handling if needed
    die($e->getMessage());
}

$campaigns = array_keys($result);
$CAMPAIGN_ID = array_pop($campaigns);

   $subscriberName =  $_POST['name'];
    $subscriberEmail =  $_POST['email'];
    $subscriberPhone =  $_POST['c_phone'];
    $subscriberCellphone =  $_POST['c_cellphone'];
    $subscriberArea =  $_POST['c_area'];
    $subscriberInsuranceType =  $_POST['c_type'];
    $subscriberCarType =  $_POST['c_cartype'];
    $subscriberManifacture =  $_POST['c_manifacture'];
    $subscriberManifacturemodel =  $_POST['c_manifacturemodel'];
    $subscriberManifactureYear =  $_POST['c_manifactureyear'];
    $subscriberDriverAge =  $_POST['c_driversage'];
    $subscriberPrevent =  $_POST['c_prevent'];
    $subscriberClaim =  $_POST['c_claim'];

try {
    $result = $client->add_contact(
        $api_key,
        array (
            'campaign'  => $CAMPAIGN_ID,
            'name'      => $subscriberName,
            'email'     =>  $subscriberEmail,
            'cycle_day' => '0',
            'customs' => array(
                array(
                    'name'       => 'home_phone',
                    'content'    => $subscriberPhone
                ),
                array(
                    'name'       => 'cell_phone',
                    'content'    => $subscriberCellphone
                ),
                array(
                    'name'       => 'living_area',
                    'content'    => $subscriberArea
                ),
                array(
                    'name'       => 'drivers_age',
                    'content'    => $subscriberDriverAge
                ),
                array(
                    'name'       => 'insurance_type',
                    'content'    => $subscriberInsuranceType
                ),
                array(
                    'name'       => 'car_type',
                    'content'    => $subscriberCarType
                ),
                array(
                    'name'       => 'manifacture_type',
                    'content'    => $subscriberManifacture
                ),
                array(
                    'name'       => 'manifacture_model',
                    'content'    => $subscriberManifacturemodel
                ),
                array(
                    'name'       => 'manifacture_year',
                    'content'    => $subscriberManifactureYear
                ),
                array(
                    'name'       => 'license_loss',
                    'content'    => $subscriberPrevent
                ),
                array(
                    'name'       => 'claims_number',
                    'content'    => $subscriberClaim
                )
            )
        )
    );
}
catch (Exception $e) {
    # check for communication and response errors
    # implement handling if needed
    die($e->getMessage());
}
}

Thanks in advance

Was it helpful?

Solution

everything was OK with this code, i GetResponse don't send confirmation requests more than once on the same email..

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top