mailjet / mailjet-apiv3-php-simple

[API v3] Simple PHP wrapper for the Mailjet API /!\ [DEPRECATED - SEE README] /!\
https://dev.mailjet.com
MIT License
55 stars 45 forks source link

Duplicate a sent newsletter #76

Closed aminebk closed 9 years ago

aminebk commented 9 years ago

Hi,

There is a method to duplicate a sent newsletter? I checked all doc here, but I didn't see how to do it. http://dev.mailjet.com/email-api/v3/newsletter-detailcontent/

It seems it was before in v1 of API https://app.mailjet.com/docs/api/message/duplicatecampaign

Thanks for any helping

arnaudbreton commented 9 years ago

Hi @aminebk,

First of all, thanks for your interest in Mailjet API!

In order to achieve this, you can use the DuplicateFrom in a POST request with the following payload '{"Status":0,"EditMode":"html"}'. Using raw PHP curl, the call will look like this:

<?
$postfields = array(
'Status' => '0',
'EditMode' => 'tool'
);

$curl = curl_init();

curl_setopt($curl, CURLOPT_URL, 'https://api.mailjet.com/v3/REST/newsletter?DuplicateFrom='.$idToDuplicate);
curl_setopt($curl, CURLOPT_HEADER, 1);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1); 
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $postfields);
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); 
curl_setopt($curl, CURLOPT_USERPWD, 'apikey:secretkey');

echo nl2br(curl_exec($curl));

Unfortunately, at the moment our wrapper doesn't support filters on POST request (only GET). We'll update it to support this and will let you know as soon as it's done. Meanwhile, we would be more than happy to integrate a Pull Request on this.

Sorry for the inconvenience, Arnaud.

arnaudbreton commented 9 years ago

Hi @aminebk,

If this issue is now solved for you, could you please close it? Don't hesitate to reach us again for further explanations, or to open a new issues if needed.

Best

WeshGuillaume commented 9 years ago

Hey @aminebk :airplane:

We just released a new PHP API wrapper. It is now more PHP-ish (including namespace, PSR-0 compliance, and globally a better architecture). All it requires is PHP 5.4

In addition to our API Guides, we would be happy to help you get started with it.

Guillaume, from Mailjet!