0

我试图从Contact Form 7WordPress 插件中获取数据并将其与 json 一起传递给GetResponse API

我有一个提取数据并发送它的 php 文件,它看起来像这样我收到了 CF7 确认电子邮件,但我没有收到时事通讯的 GetResponse 电子邮件确认,我不明白为什么,我试图做一些调试并且没有错误

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());
}
}

提前致谢

4

1 回答 1

0

这段代码一切正常,我 GetResponse 不会在同一封电子邮件上多次发送确认请求..

于 2012-11-28T18:36:54.563 回答