Add subscriber to client list

Hi,

I am attempting to add a subscriber to a list under a client via the php subscriber wrapper.

If i use the master api and the list api i get "invalid ListId"

If i use the client api and list id i get "Must supply a valid HTTP Basic Authorization header"

Im guessing the problem is with the authentication and i cant see if there is a different process if the list is under a client.

I have used the same code successfully on a list under top level control.

Any help appreciated

Thanks

jamesd jamesd, 4 years ago

Hey,

Firstly, please make sure you're getting your API key and list ID as instructed in the docs.

Then try the following code (taken from the sample included in the PHP wrapper), after setting your list ID and API key in the first line:

$wrap = new CS_REST_Subscribers('Your list ID', 'Your API Key');
$result = $wrap->add(array(
    'EmailAddress' => 'example@example.com',
    'Name' => 'Example Subscriber',
    'CustomFields' => array(),
    'Resubscribe' => true
));

echo "Result of POST /api/v3/subscribers/{list id}.{format}\n<br />";
if($result->was_successful()) {
    echo "Subscribed with code ".$result->http_status_code;
} else {
    echo 'Failed with code '.$result->http_status_code."\n<br /><pre>";
    var_dump($result->response);
    echo '</pre>';
}
rumbleg :

Im guessing the problem is with the authentication and i cant see if there is a different process if the list is under a client.

I have used the same code successfully on a list under top level control.

All lists belong to a client in Campaign Monitor, but for the purpose of this API call you just need the list ID and your API key.

Also, for future reference, you'll usually receive more useful help if you post the code you're having trouble with.

Join 200,000 companies around the world that use Campaign Monitor to run email marketing campaigns that deliver results for their business.

Get started for free
1-888-533-8098