constantcontact / php-sdk

Constant Contact PHP SDK for v2 API
Other
105 stars 125 forks source link

Bad Request Using v3 #140

Closed moebaca closed 7 years ago

moebaca commented 7 years ago

edit Upon more debugging I've found this so I might end up closing this if I can figure it out as it actually seems that the v3 is A-OK:

stdClass Object ( [error_key] => json.regex.mismatch.email_content [error_message] => #/email_content: This attribute value must be of the format '...' ) stdClass Object ( [error_key] => json.field.lists.value.invalid [error_message] => The contact list laravel does not exist. )

edit2 Great library. My fail. Closing.. Thanks!

Good morning,

I am using the version 3 branch due to Laravel using Gulp 6 and have run into an issue. I am able to successfully pull data from my account, such as getting a user, but run into an issue when creating a new campaign. I have followed the code in your examples folder titled "createAndScheduleCampaign.php" very closely. I've examined my object campaign object that I am passing over and it is meeting all of the criteria in this document:

https://developer.constantcontact.com/docs/email-campaigns/email-campaign-api-index.html#ui-v-api

Here is my code:

    define("APIKEY", "my key");
    define("ACCESS_TOKEN", "my token");

    $cc = new ConstantContact(APIKEY);

    $date = date('Y-m-d\TH:i:s\.000\Z', strtotime("+1 month"));
    $campaign = new Campaign();
    $campaign->name = 'Help Desk Agreement Renewal - ' . $date;
    $campaign->subject = 'Test Campaign via Laravel';
    $campaign->from_name = 'Laravel';
    $campaign->from_email = 'my verified email';
    $campaign->greeting_string = 'Hello';
    $campaign->reply_to_email = 'my verified email';
    $campaign->text_content = 'Taco Tuesday FTW';
    $campaign->email_content = 'blahblahblah';
    $campaign->addList('1593322660'); //This is for sure a valid contact ID, it is me

// dd($campaign);

    return $cc->emailMarketingService->addCampaign(ACCESS_TOKEN, $campaign);

Any ideas why I might be getting this error:

CtctException in BaseService.php line 100: Bad Request in BaseService.php line 100 at BaseService->convertException(object(ClientException)) in EmailMarketingService.php line 35 at EmailMarketingService->addCampaign('my token', object(Campaign)) in ConstantContactIntegration.php line 68

I am concerned it is because I am on that alpha branch, but have read from other posts it should 'probably' be golden!

Note I've also just tested creating a user with the same example code and receive another Bad Request error.

Thanks in advance,