2011-12-13 32 views
0

我使用sendgrid的事件的API,它發送一個代碼塊這樣我選擇的回髮網址與紅寶石請求數據:如何分析

Array 
(
    [email] => [email protected] 
    [timestamp] => 1323698899 
    [smtp-id] => <[email protected]> 
    [response] => 250 2.0.0 OK 1323698899 o30s15072o427yhl.103 
    [event] => delivered 
) 

他們沒有XML或JSON,我需要提取該塊的電子郵件和事件部分。

任何想法,我如何做到這一點與鐵軌?基本上這個塊被髮送到我選擇的回發URL,但我不知道如何從那裏使用它。

+0

根據他們的Web API頁面(http://docs.sendgrid.com/documentation/api/web-api/),他們*具有XML和JSON。這不適用於他們的事件API嗎? –

回答

0

我從來沒有使用sendgrid但咋一看後,好像他們只是向您發送帶有參數的標準post請求,所以你最好的賭注是定義像下面這樣一個簡單的動作,看看你會得到什麼:

def sendgrid_event 
    Rails.logger.info(params) 

    # chances are that this will contains what you are looking for: 
    # params['email'] 
    # params['event'] 

end