Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/279.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何通过API将lead发送到Getresponse_Php_Html_Api_List_Getresponse - Fatal编程技术网

Php 如何通过API将lead发送到Getresponse

Php 如何通过API将lead发送到Getresponse,php,html,api,list,getresponse,Php,Html,Api,List,Getresponse,我有一个收集姓名和电子邮件地址的html表单。我尝试使用以下脚本将这些信息提交到GetResponse列表: <?php function mytheme_save_to_getresponse($form) { require_once 'jsonRPCClient.php'; $api_key = 'myAPIkey'; $api_url = 'http://api2.getresponse.com'; $client = new jsonRPCCl

我有一个收集姓名和电子邮件地址的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没有将lead保存到我的列表中。我做错什么了吗

谢谢
James

您的代码看起来不错,您必须为错误处理设置回拨url

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

此行错误:

'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 } ?>

你能再具体一点吗?