从Facebook API调用返回的对象获取Id

时间:2017-03-27 17:14:51

标签: php

我是PHP的初学者,我正在编写用PHP创建leadgen表单的程序,成功创建了from,我得到了结果,我需要从中提取数组中表单的ID:

[decodingBody:protected] =>排列         (             [id] => 492142887842958         )

但我无法做到。收到的整个回复如下:

Facebook\FacebookResponse Object
(
    [httpStatusCode:protected] => 200
    [headers:protected] => Array
        (
            [Access-Control-Allow-Origin] => *
            [Pragma] => no-cache
            [Cache-Control] => private, no-cache, no-store, must-revalidate
            [x-fb-rev] => 2916529
            [Content-Type] => application/json; charset=UTF-8
            [x-fb-trace-id] => HM8UnSdNxRB
            [facebook-api-version] => v2.8
            [Expires] => Sat, 01 Jan 2000 00:00:00 GMT
            [Vary] => Accept-Encoding
            [X-FB-Debug] => 3U8j5LnZ1ajsdadjkahdaghgaghjsaT0bug8laaYZ76x/luSEE739o9PbhPWI4bhqHeiQ==
            [Date] => Mon, 27 Mar 2017 14:34:33 GMT
            [Connection] => keep-alive
            [Content-Length] => 24
        )

    [body:protected] => {"id":"492142887842958"}
    [decodedBody:protected] => Array
        (
            [id] => 492142887842958
        )

    [request:protected] => Facebook\FacebookRequest Object
        (
            [app:protected] => Facebook\FacebookApp Object
                (
                    [id:protected] => 648348958680834
                    [secret:protected] => a0de79ae677d261957b4364542fcdcb
                )

            [accessToken:protected] => EAAJNq6zieJIBACqYTsBqgvNkGDapttVwhZASxJ5W1FPZAtpG13rlLicwrQNJe4EZC0okC6igyZBrKoUWmYHQpypV37e1R91xbm6ZCeZAyzbBlhbRXwUgkzhZBZAH1jOjZAXKp4iDpNIS7uPNefKx9WiQaadIcSDAZDZD
            [method:protected] => POST
            [endpoint:protected] => /7791884894542621/leadgen_forms?name=FromfromAPI&follow_up_action_url=www.example.io&privacy_policy=%7B%22url%22%3A%22www.example.info%22%7D&questions=%5B%7B%22type%22%3A%22EMAIL%22%7D%2C%7B%22type%22%3A%22CUSTOM%22%2C%22label%22%3A%22FULL_NAME%22%7D%2C%7B%22type%22%3A%22CUSTOM%22%2C%22label%22%3A%22PHONE%22%7D%5D
            [headers:protected] => Array
                (
                    [Content-Type] => application/x-www-form-urlencoded
                )

            [params:protected] => Array
                (
                    [app_id] => 648348958680834
                )

            [files:protected] => Array
                (
                )

            [eTag:protected] => 
            [graphVersion:protected] => v2.5
        )

    [thrownException:protected] => 
)

1 个答案:

答案 0 :(得分:0)

由于您尚未提供任何代码。如果您的结果在$ object中,那么您可以将ID作为

light.exe [other parameters] -cultures:en-US