Mandrill ValidationError

后端 未结 7 2506
花落未央
花落未央 2021-02-20 06:51

Very excited to be asking my first question on StackOverflow. I\'ve been relying on it to teach myself quite a lot over the years!

My question is this. I am getting the

7条回答
  •  隐瞒了意图╮
    2021-02-20 07:08

    Have been experimenting with Dan's curl setup to post html enriched messages to Mandrill, but this time using html in the template_content: [] array of the message/send-template.json api.

    What i noticed was that this setup (fix by Bansi included) seemed to work in Mandrill's try out page : https://mandrillapp.com/api/docs/messages.JSON.html#method=send-template

    But in my php script, i kept receiving this stubborn You must specify a key value error. Apparantly thanks to this thread, i solved the issue by adding utf8 as charset to the request headers:

    $ch = curl_init();
    $headers = array("Content-type: application/json;charset=\"utf-8\""); 
    curl_setopt($ch, CURLOPT_URL, $uri);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true );
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true );
    curl_setopt($ch, CURLOPT_HTTPHEADER,$headers);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $postString);
    
    $result = curl_exec($ch);
    

提交回复
热议问题