这可能很简单,但我正撞在墙上。
我正在尝试解析Mailgun通过webhook发送到我的应用程序的数据。
所以我设置了一个简单的脚本来测试: -
<?php
if(!empty($_POST))
{
$file = fopen('mail'.time().'.txt','w');
ob_start();
var_dump($_POST);
fwrite($file, ob_get_clean());
fclose($file);
}
?>
是的 - 我知道它很难看。
我收到回复,写入文件没问题。
问题是响应的附件部分没有以这种方式被接收。
下面的Django代码说明了你的意图 - 但我显然要么是厚的还是菜鸟,因为我无法理解如何获得PHP的等价物
def on_incoming_message(request):
if request.method == 'POST':
sender = request.POST.get('sender')
recipient = request.POST.get('recipient')
subject = request.POST.get('subject', '')
body_plain = request.POST.get('body-plain', '')
body_without_quotes = request.POST.get('stripped-text', '')
for key in request.FILES:
file = request.FILES[key]# note: other MIME headers are also posted here...
# attachments:
# do something with the file
return HttpResponse('OK')
我有点愚蠢的是
for key in request.FILES:
file = request.FILES[key]# note: other MIME headers are also posted here...
如何访问“外部”部分&#39; POST
请求。
为清楚起见: -
感谢您的帮助 - 我为这是多么简单而哭泣,事实上我被困住了,但迫切需要一副新鲜的眼睛!