如何阅读Laravel中Facebook Leadgen webhook的输入

时间:2017-08-15 20:15:45

标签: php facebook laravel laravel-5.4

输入如下:

public function webhook(Request $request)
{
    dd($request->input);
}

// output
[{
    "entry":[{
        "changes":[{
            "field":"leadgen",
            "value":{
                "ad_id":0,
                "form_id":724269564418666,
                "leadgen_id":8144548420666,
                "created_time":1502824666,
                "page_id":482428225170666,
                "adgroup_id":0
            }
        }],
        "id":"48242822517",
        "time":1502824702
    }],
    "object":"page"
}] 



$input[0]->entry[0]->changes[0]->value; // Undefined Offset 0

1 个答案:

答案 0 :(得分:0)

Facebook正在返回的数据为JSON格式。您需要使用PHP的json_decode()函数将数据转换为可用格式,例如:

beginTransaction()