Keep getting an Invalid Date Error on getUnsubscribes

I keep getting this error
[code]Array
(
    [Subscribers.GetUnsubscribedResult] => Array
        (
            [code] => 5
            [Message] => Invalid date
        )

)[/code]
Whenever I send this to getUnsubscribes API method:
[code]Array
(
    [ApiKey] => 92a40e5bfa0dbe67d14ee2fa8a1efc48bb0b8b54
    [ListID] => 276443
    [Date] => '2008-02-12 15:11:03'
)[/code]
Whats wrong with my Date? Im using PHP4 with NUSOAP btw.
CHeers!

Toby Brain, 8 years ago

I have had a look at this and cannot reproduce the error.

If you could provide any more information about it, including the PHP files used, I can look into the issue further.

Just to confirm the only way that an Invalid Date error can be raised is if the date cannot be parsed by .Net environment.

hwz, 8 years ago
$yesterday = date("Y-m-d H:i:s",strtotime("-1 day"));     //yesterday 'YYYY-MM-DD HH:MM:SS'
foreach($subscriptions as $api_list_id=>$subscription):
    /* List Unsubscribes over the past 24hrs */
    $params = array('ApiKey' => $cm_api_key,
                    'ListID' => $api_list_id,
                    'Date' => "'".$yesterday."'");
                    print_r($params);
    $unsubs = $soapclient->call('GetUnsubscribes',$params,'http://app.campaignmonitor.com/api/','http://app.campaignmonitor.com/api/');
    //$unsubs = getUnSubUserIds($unsubs);//simplify unsubs output into userid-array
    print_r($unsubs);
    /*Unsubscribe per user*/
    /*foreach($unsubs as $unsub):
        $parameters = array($api_key,$unsub['userid'],$subscription);
        $soapclient2->call('ws_unSubscribeMember',$parameters);
    endforeach;*/

    /* List email-bounces of the list */
     $params = array('ApiKey' => $cm_api_key,
                    'ListID' => $api_list_id,
                    'Date' => "'".$yesterday."'");
    $bounces = $soapclient->call('GetBouncedSubscribers',$params);

Hi Toby,
This is the code-segment which I used to generate the SOAP requests I sent earlier.Could you give me an example of a .NET friendly Date?
Cheers!

Toby Brain, 8 years ago

hwz:

The problem is that you are enclosing the date within ' ' i.e the string that we are receiving is "'2008-02-12 15:11:03'", I should have picked this up earlier sorry just looked over it. 

The following example should work: note $yesterday is simply inserted into the $params array

    $params = array('ApiKey' => $cm_api_key,
                    'ListID' => $api_list_id,
                    'Date' => $yesterday);

    print_r($params);

We have added error checking for date enclosed within quotes which will go live on the next update

Join 150,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