Skip to content
Advertisement

Json Parsing and inserting to mysql

I am using the the Mandrill to post any inbound emails. Here is what is posted by Mandrill when i receive a new email -> http://help.mandrill.com/entries/22092308-What-is-the-format-of-inbound-email-webhooks-

Also here is what i get in the $_REQUEST (sorry that its not formatted well): [{"event":"inbound","ts":1361798154,"msg":{"raw_msg":"Received: from nm11-vm1.bullet.mail.sg3.yahoo.com (nm11-vm1.bullet.mail.sg3.yahoo.com [106.10.148.240])\n\tby ip-10-138-250-144 (Postfix) with ESMTPS id 663A4136204D\n\tfor <>; Mon, 25 Feb 2013 13:15:54 +0000 (UTC)\nReceived: from [106.10.166.112] by nm11.bullet.mail.sg3.yahoo.com with NNFMP; 25 Feb 2013 13:15:53 -0000\nReceived: from [106.10.151.171] by tm1.bullet.mail.sg3.yahoo.com with NNFMP; 25 Feb 2013 13:15:53 -0000\nReceived: from [127.0.0.1] by omp1011.mail.sg3.yahoo.com with NNFMP; 25 Feb 2013 13:15:53 -0000\nX-Yahoo-Newman-Property: ymail-3\nX-Yahoo-Newman-Id: 250040.22861.bm@omp1011.mail.sg3.yahoo.com\nReceived: (qmail 28099 invoked by uid 60001); 25 Feb 2013 13:15:53 -0000\nDKIM-Signature: v=1; a=rsa-sha256; c=relaxed\/relaxed; d=yahoo.co.in; s=s1024; t=1361798153; bh=BDFj0kYtFyAwYeMROJlckEQlebiL67q4OCeBIQv8Ptg=; h=X-YMail-OSG:Received:X-Rocket-MIMEInfo:X-Mailer:Message-ID:Date:From:Reply-To:Subject:To:MIME-Version:Content-Type; b=JTaQH8PfSRIt\/tYN16h6m1TeqlfEilid7FHTCoLdgYKL1CKf1s92DXm0vNKycLvTK7vmGr61e8SOxv2yGghCgOFHEumbLrF0kz+dhDeXBzyqrMPLcXT0w4uiUTJv+YtlsXYELvzN2ULhVwE1BXst2ok\/Fj5AxpmRSJ8\/0lxxUrY=\nDomainKey-Signature:a=rsa-sha1; q=dns; c=nofws;\n s=s1024; d=yahoo.co.in;\n h=X-YMail-OSG:Received:X-Rocket-MIMEInfo:X-Mailer:Message-ID:Date:From:Reply-To:Subject:To:MIME-Version:Content-Type;\n b=fEBcmdXcrijuQ\/LkRh3mlZVEdQ7E\/DzZ2rRlMZEUbr2Z6sv0SbmADNiea4a4WZImIJTyeXdgeOTrV1peLkegTUzf5UxBQW18NE0Sjlay54kAhADfgt6N+HUoiSH+Psj4gTSbOYv\/Ij1x2CmR645JShaz2x1TfNYgvYRb05VZWv8=;\nX-YMail-OSG: buuv6IIVM1kj3NrZiivkBVYfFcT.P8xs1KJk1zKUlFASQ5M\n 0rxt7ojMEC0KSn8S8s4GSaBBW.f4Pd8x9V4dCr8BPKXvnvcZQhqM2Wu10meZ\n jC.N8I7D3XXxzRI15ez1zICJg2fZkng2x5FQqUhElC.y03G6cSZJIFPSBitM\n 0R6RnJA0zhWnWQv7UAD.KdKiKgnEPSA9lZpRqcTGHh8uNYuu6bWiKv9wXnGG\n rzKei4dmAv5lrEhD9iXVSQCQw_2S9RzQd08B3vBg0keF3vBMBnmCCdyqdxRK\n 4IQbYZZGBXTt3AQz.rdVxjTicu2rTvkGLkOb9JN0qA3NURs2BJYvd0TMNGQn\n 9xWGKTIQmJ.pla6Tw8_vQUCkJuRCl7tlKavXX6U_ocY34VjDTthwKHf.pCYo\n 8mwtfsLpHC9ZklRu4vSIM6kGZLjQoux4mz0qJduVBaYYoRboY_kH622MyI.m\n sBA--\nReceived: from [182.68.19.112] by web192402.mail.sg3.yahoo.com via HTTP; Mon, 25 Feb 2013 21:15:52 SGT\nX-Rocket-MIMEInfo: 001.001,U2F5cyBXaG8BMAEBAQE-\nX-Mailer: YahooMailWebService\/0.8.134.513\nMessage-ID: <1361798152.24847.YahooMailNeo@web192402.mail.sg3.yahoo.com>\nDate: Mon, 25 Feb 2013 21:15:52 +0800 (SGT)\nFrom: Lucky Soni <lp.soni@yahoo.co.in>\nReply-To: Lucky Soni <lp.soni@yahoo.co.in>\nSubject: Hello World\nTo: \"\" <>\nMIME-Version: 1.0\nContent-Type: multipart\/alternative; boundary=\"1577518589-1280633723-1361798152=:24847\"\n\n--1577518589-1280633723-1361798152=:24847\nContent-Type: text\/plain; charset=utf-8\nContent-Transfer-Encoding: quoted-printable\n\nSays Who\n--1577518589-1280633723-1361798152=:24847\nContent-Type: text\/html; charset=utf-8\nContent-Transfer-Encoding: quoted-printable\n\n<html><body><div style=3D\"color:#000; background-color:#fff; font-family:ve=\nrdana, helvetica, sans-serif;font-size:12pt\"><div>Says Who<\/div><\/div><\/bod=\ny><\/html>\n--1577518589-1280633723-1361798152=:24847--","headers":{"Received":["from nm11-vm1.bullet.mail.sg3.yahoo.com (nm11-vm1.bullet.mail.sg3.yahoo.com [106.10.148.240]) by ip-10-138-250-144 (Postfix) with ESMTPS id 663A4136204D for <>; Mon, 25 Feb 2013 13:15:54 +0000 (UTC)","from [106.10.166.112] by nm11.bullet.mail.sg3.yahoo.com with NNFMP; 25 Feb 2013 13:15:53 -0000","from [106.10.151.171] by tm1.bullet.mail.sg3.yahoo.com with NNFMP; 25 Feb 2013 13:15:53 -0000","from [127.0.0.1] by omp1011.mail.sg3.yahoo.com with NNFMP; 25 Feb 2013 13:15:53 -0000","(qmail 28099 invoked by uid 60001); 25 Feb 2013 13:15:53 -0000","from [182.68.19.112] by web192402.mail.sg3.yahoo.com via HTTP; Mon, 25 Feb 2013 21:15:52 SGT"],"X-Yahoo-Newman-Property":"ymail-3","X-Yahoo-Newman-Id":"250040.22861.bm@omp1011.mail.sg3.yahoo.com","Dkim-Signature":"v=1; a=rsa-sha256; c=relaxed\/relaxed; d=yahoo.co.in; s=s1024; t=1361798153; bh=BDFj0kYtFyAwYeMROJlckEQlebiL67q4OCeBIQv8Ptg=; h=X-YMail-OSG:Received:X-Rocket-MIMEInfo:X-Mailer:Message-ID:Date:From:Reply-To:Subject:To:MIME-Version:Content-Type; b=JTaQH8PfSRIt\/tYN16h6m1TeqlfEilid7FHTCoLdgYKL1CKf1s92DXm0vNKycLvTK7vmGr61e8SOxv2yGghCgOFHEumbLrF0kz+dhDeXBzyqrMPLcXT0w4uiUTJv+YtlsXYELvzN2ULhVwE1BXst2ok\/Fj5AxpmRSJ8\/0lxxUrY=","Domainkey-Signature":"a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.co.in; h=X-YMail-OSG:Received:X-Rocket-MIMEInfo:X-Mailer:Message-ID:Date:From:Reply-To:Subject:To:MIME-Version:Content-Type; b=fEBcmdXcrijuQ\/LkRh3mlZVEdQ7E\/DzZ2rRlMZEUbr2Z6sv0SbmADNiea4a4WZImIJTyeXdgeOTrV1peLkegTUzf5UxBQW18NE0Sjlay54kAhADfgt6N+HUoiSH+Psj4gTSbOYv\/Ij1x2CmR645JShaz2x1TfNYgvYRb05VZWv8=;","X-Ymail-Osg":"buuv6IIVM1kj3NrZiivkBVYfFcT.P8xs1KJk1zKUlFASQ5M 0rxt7ojMEC0KSn8S8s4GSaBBW.f4Pd8x9V4dCr8BPKXvnvcZQhqM2Wu10meZ jC.N8I7D3XXxzRI15ez1zICJg2fZkng2x5FQqUhElC.y03G6cSZJIFPSBitM 0R6RnJA0zhWnWQv7UAD.KdKiKgnEPSA9lZpRqcTGHh8uNYuu6bWiKv9wXnGG rzKei4dmAv5lrEhD9iXVSQCQw_2S9RzQd08B3vBg0keF3vBMBnmCCdyqdxRK 4IQbYZZGBXTt3AQz.rdVxjTicu2rTvkGLkOb9JN0qA3NURs2BJYvd0TMNGQn 9xWGKTIQmJ.pla6Tw8_vQUCkJuRCl7tlKavXX6U_ocY34VjDTthwKHf.pCYo 8mwtfsLpHC9ZklRu4vSIM6kGZLjQoux4mz0qJduVBaYYoRboY_kH622MyI.m sBA--","X-Rocket-Mimeinfo":"001.001,U2F5cyBXaG8BMAEBAQE-","X-Mailer":"YahooMailWebService\/0.8.134.513","Message-Id":"<1361798152.24847.YahooMailNeo@web192402.mail.sg3.yahoo.com>","Date":"Mon, 25 Feb 2013 21:15:52 +0800 (SGT)","From":"Lucky Soni <lp.soni@yahoo.co.in>","Reply-To":"Lucky Soni <lp.soni@yahoo.co.in>","Subject":"Hello World","To":"\"\" <>","Mime-Version":"1.0","Content-Type":"multipart\/alternative; boundary=\"1577518589-1280633723-1361798152=:24847\""},"text":"Says Who\n","html":"<html><body><div style=\"color:#000; background-color:#fff; font-family:verdana, helvetica, sans-serif;font-size:12pt\"><div>Says Who<\/div><\/div><\/body><\/html>\n","from_email":"lp.soni@yahoo.co.in","from_name":"Lucky Soni","to":[["",""]],"subject":"Hello World","email":"","tags":[],"sender":null}}]

I need to get the “text” (please use “ctrl/command + F” to find the word “text” 🙂 and then insert into mySQl. Please help. Thanks

Note: I have already tried json_deocde but it does not work gor me.

Advertisement

Answer

Have you try to decode your json with json_deocde ? https://www.php.net/manual/en/function.json-decode.php

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement