Wie zum senden von E-Mails über MailChimp 3.0-api?

Ich versuche zum senden von E-Mails über mailchimp api-version 3.0 in php, aber ich habe kein Glück. Das ist mein code:

$postString = '{
        "message": {
            "html": "this is the emails html content",
            "text": "this is the emails text content",
            "subject": "this is the subject",
            "from_email": "[email protected]",
            "from_name": "John",
            "to_email": "[email protected]",
            "to_name": "Anton",
            "track_opens": false,
            "track_clicks": false
        }}';

        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $this->api_endpoint);
        curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); 
        curl_setopt($ch, CURLOPT_USERPWD, 'drewm:'.$this->api_key);
        curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: application/vnd.api+json', 'Content-Type: application/vnd.api+json'));
        curl_setopt($ch, CURLOPT_USERAGENT, 'DrewM/MailChimp-API/3.0 (github.com/drewm/mailchimp-api)');
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true );
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true );
        curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, $this->verify_ssl);
        curl_setopt($ch, CURLOPT_POST, true);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $postString);
        curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);

        $result = curl_exec($ch);

        echo $result;

Was mache ich falsch?

InformationsquelleAutor Anton Smatanik | 2015-07-30

Schreibe einen Kommentar