2011-12-19 6 views
0

私は電子メールを送信するためにPostmarkを使用しています。 しかし、消印は、返送された電子メールを処理するためのURLを設定することを可能にします。 私はこれを使用したいが、データを取得して処理する方法を知らない。Parse Postmark PHPのバウンスフック

私のAPIは機能しますが、私のAPIに送信するデータを取得する方法はわかりません。

<?php 

class BackendBillingAPI 
{ 
    public static function postmarkBounceHook() 
    { 
     $log = new SpoonLog('custom', PATH_WWW . '/backend/cache/logs/billing'); 

     // logging when we are in debugmode 
     if(SPOON_DEBUG) $log->write('Billing post (' . serialize($_POST) . ') triggered.'); 
     if(SPOON_DEBUG) $log->write('Billing get (' . serialize($_GET) . ') triggered.'); 
     if(SPOON_DEBUG) $log->write('Billing _REQUEST (' . serialize($_REQUEST) . ') triggered.'); 

    } 
} 

どのような考えですか?

答えて

1

あなたはPOST内部のJSONデータを解析する必要があるだろう、とあなたは明らかに_POSTに頼ることができない(これはマルチパート形式ではないので、詳細はthisを参照)

ここでは簡単なコードことがありますはがきからいくつかのパラメータを取得し、電子メールを生成します。パラメータを取得して、もちろん必要なものを実行することができます。

<?php 
$form_data = json_decode(file_get_contents("php://input")); 

// If your form data has an 'Email Address' field, here's how you extract it:  
$email_address = $form_data->Email; 
$details = $form_data->Details; 
$type = $form_data->Type; 

// Assemble the body of the email...            
$message_body = <<<EOM 
Bounced Email Address: $email_address 
Details: $details 
Type: $type 
EOM; 
if ($email_address) { 
    mail('ENTER YOUR EMAIL ADDRESS', 
     'Email bounced!', 
     $message_body); 
} 
?>