PHP API Function calls getsinglesubscriber & subscribersGetActive

Hey Folks,

I'm writing a silly little script playing the CM API and I was looking at the examples for inspiration and explanation for how to get getsinglesubscriber to work, I can's find any PHP references to work.

I've tried calling

->subscribersGetSingleSubscriber, ->getSingleSubscriber, ->subscriberGetSingleSubscriber

and all come back with a function non existent response.

So I checked in the CMbase.php file and couldn't find the function

getsinglesubscriber

. I couldn't find any examples in the PHP examples file.

There is also not an example of subscribersGetActive function, but just in case anyone else comes across this issue and needs a hand the format is as such:

$aListOfAllActiveSubscribers = $cm->subscribersGetActive('YYYY-MM-DD HH:MM:SS', $theListYouWantToGetDetailsFrom);

I hope it's of help to someone, and maybe someone can tell me the call for single subscribers.

Thanks All

blad, 7 years ago

Hi
Here's some extra code to add into CMBase.php that will give you GetSingleSubscriber

    function subscribersGetSingleSubscriber( $email = '', $list_id = null, $action = 'Subscribers.GetSingleSubscriber' )
    {
        if ( !$list_id )
            $list_id = $this->list_id;
        
        return $this->makeCall( $action
            , array( 
                'params' => array( 
                    'ListID' => $list_id 
                    , 'EmailAddress' => $email
                )
            )
        );
    }

A small script to use it:

// setup all your API/Client ID vars first.
$cm = new CampaignMonitor( $api_key, $client_id, $campaign_id, $list_id );
$email = 'youremail@address.com.au';
$result = $cm->subscribersGetSingleSubscriber("$email","$list_id");

Note: I found the array returns to be problematic in PHP (CM are looking into this), and have made another posting on how to get the PHP CMBase object to spit out XML, which you can then use PHP to parse.

Also - remember this function searches for an email address in a list you provide. It doesn't do a 'search all lists'.

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