Getresponse查找联系人以查看是否存在

时间:2015-09-21 09:44:48

标签: php json api getresponse

我有这个代码在GetResponse中查找联系人以查看它是否存在。 第一部分(获取活动)有效,但在异常中获取联系失败:请求返回错误:无效的参数:

<?php
$jsonfile = 'jsonrpcclient.php';

if (file_exists($jsonfile)) 
    {
        require_once $jsonfile;
        $api_key = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
        $api_url = 'http://api2.getresponse.com';
        $client = new jsonRPCClient($api_url);
        $result = NULL;

        // Get campaign
        try
            {
                $result = $client->get_campaigns(
                    $api_key,
                    array (
                        'name' => array ( 'EQUALS' => 'my_customer_list' )
                    )
                );
            }

        catch (Exception $e)
            {
                die($e->getMessage());
            }

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

        // Lookup contact
        try
            {
                $result = $client->get_contacts(
                    $api_key,
                    array (
                        'campaigns' => $CAMPAIGN_ID,
                        'email'     => $track_order_email
                    )
                );
            }

        catch (Exception $e)
            {
                die($e->getMessage());
            }               


    }
else
    {
        echo "Json include file NOT found";
    }

?>

格式化get_contacts参数时,我们将不胜感激。

1 个答案:

答案 0 :(得分:0)

正如我在此解释的那样:Getresponse API 2 (Adding Custom fields and contacts using PHP)

您的两个参数的格式应不同。

而不是:

array (
    'campaigns' => $CAMPAIGN_ID,
    'email'     => $track_order_email
)

它应该是:

array (
    'campaigns' => array( $CAMPAIGN_ID ),
    'email'     => array( 'EQUALS' => $track_order_email )
)
祝你好运! :)