1

I have this code to find a contact in GetResponse to see if it exists. The first part (getting the campaign) works, but getting the contact fails in an exception: Request have return error: Invalid params:

<?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";
    }

?>

Any help would be appreciated in formatting the get_contacts parameters.

  • why dont you check `get_contacts` method definition in your `jsonRPCClient` class, to see which params it requires? – Alex Chorry Sep 21 '15 at 10:06

1 Answers1

0

As I explained here: Getresponse API 2 (Adding Custom fields and contacts using PHP)

both of your parameters should be formatted differently.

Instead of:

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

it should be:

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

Good luck! :)

Community
  • 1
  • 1
Olga Farber
  • 306
  • 2
  • 7