doue2666 2017-05-04 18:05
浏览 140

Mailgun Webhook跟踪事件:如何将输出传递给数据库

I am using a Mailgun Webhook to track events (delivered, opened, etc). I successfully redirected the event to a url that has a php file that looks like this:

<?php

$postdata = file_get_contents("php://input");
$postdata_encoded = json_encode($_POST['message-headers']);

When I echo the output I am getting the following:

[[\"Received\", \"by luna.mailgun.net with SMTP mgrt 8734663311733; Fri, 03 May 2013 18:26:27 +0000\"], [\"Content-Type\", [\"multipart/alternative\", {\"boundary\": \"eb663d73ae0a4d6c9153cc0aec8b7520\"}]], [\"Mime-Version\", \"1.0\"], [\"Subject\", \"Test deliver webhook\"], [\"From\", \"Bob \"], [\"To\", \"Alice \"], [\"Message-Id\", \"<20130503182626.18666.16540@mail.example.com>\"], [\"X-Mailgun-Variables\", \"{\\"my_var_1\\": \\"Mailgun Variable #1\\", \\"my-var-2\\": \\"awesome\\"}\"], [\"Date\", \"Fri, 03 May 2013 18:26:27 +0000\"], [\"Sender\", \"bob@mail.example.com\"]]

Question: How can I transform this output to a proper json format that I will be able to pass to my database? I tried something like this:

$output = array();
foreach ($postdata_encoded as $key=>$value) {
    $output[$key] = $value;
}
var_dump($output);

but this returns:

Response: array(0) { }

Any idea? Many thanks

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
    • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?
    • ¥15 乘性高斯噪声在深度学习网络中的应用
    • ¥15 运筹学排序问题中的在线排序
    • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
    • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
    • ¥15 C++ 头文件/宏冲突问题解决
    • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
    • ¥50 安卓adb backup备份子用户应用数据失败
    • ¥20 有人能用聚类分析帮我分析一下文本内容嘛