【问题标题】:How to send lead via API to Getresponse如何通过 API 将潜在客户发送到 Getresponse
【发布时间】:2013-01-17 18:09:35
【问题描述】:

我有一个 html 表单,其中收集了姓名和电子邮件地址。我尝试使用此脚本将这些信息提交到 GetResponse 列表:

<?php

function mytheme_save_to_getresponse($form)
{

    require_once 'jsonRPCClient.php';
    $api_key = 'myAPIkey';
    $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' => 'testlist' )
        )
    );
}
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);

    $subscriberEmail =  $_GET['email'];

try {
    $result = $client->add_contact(
        $api_key,
        array (
            'campaign'  => $CAMPAIGN_ID,
            'name'     =>  $subscriberName,
            'email'     =>  $subscriberEmail,
            'cycle_day' => '0'
                    )
    );
}
catch (Exception $e) {
    # check for communication and response errors
    # implement handling if needed
    die($e->getMessage());
}
}
?>

脚本未显示任何错误,但 GetResponse 未将潜在客户保存到我的列表中。我做错了吗?

谢谢 詹姆斯

【问题讨论】:

    标签: php html api list getresponse


    【解决方案1】:

    如果您收到 [queued]=>1 的响应,那么您的脚本工作正常。 只有在验证/确认输入的电子邮件后才会将其添加到您的联系人中 $subscriberEmail 将收到一封确认电子邮件...在用户单击链接后,联系人将被添加

    【讨论】:

      【解决方案2】:

      这一行是错误的:

      'name'     =>  $subscriberName,
      

      因为您有未定义的变量并将其发布到没有值的 GetResponse API 'name' 参数,因此 GetResponse API 返回无效参数。

      改为:

      $subscriberName => "Some_test_name", // for test only
      

      在这一行:

      $subscriberEmail =  $_GET['email'];
      

      您应该在 GET 表中设置一些电子邮件,也许为了测试只需更改为:

      $subscriberEmail =  "test@domain.com"; // or sth like this.
      

      最后一个想法是 var_dump $result 变量,然后您会看到来自 GetResponse API 的响应

      $result = null; // before try {
      
      var_dump($result); // before end of function } ?>
      

      【讨论】:

        【解决方案3】:

        您的代码看起来不错,您必须设置回调 url 以进行错误处理

        【讨论】:

        • 你能说得更具体一点吗?
        猜你喜欢
        • 2023-03-29
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-01-31
        • 1970-01-01
        相关资源
        最近更新 更多