0

Facebook POST request from lead ads test tool is getting transformed on my end:

Facebook lead ad testing tool: https://developers.facebook.com/tools/lead-ads-testing

Code to accept payload:

$input = json_decode(file_get_contents('php://input'), true);

Framework: CakePHP 2.0

Debug:

2017-07-07 12:12:27 Debug: Array
(
    [entry] => Array
        (
            [0] => Array
                (
                    [changes] => Array
                        (
                            [0] => Array
                                (
                                    [field] => leadgen
                                    [value] => Array
                                        (
                                            [ad_id] => 0
                                            [form_id] => 7.2426956441826E+14
                                            [leadgen_id] => 7.9242177426971E+14
                                            [created_time] => 1499447542
                                            [page_id] => 4.8242822517084E+14
                                            [adgroup_id] => 0
                                        )

                                )

                        )

                    [id] => 482428225170841
                    [time] => 1499447543
                )

        )

    [object] => page
)

PHP versions: 5.5.9

The problem:

[form_id] => 7.2426956441826E+14
[leadgen_id] => 7.9242177426971E+14

When it should be:

[form_id] => 724269564418262
[leadgen_id] => 792421774269707

So it seems to be converting those numbers for some reason.

I have a clone of this app on an older version of PHP ( 5.4 ) and dont seems to be having this issue there.

Angad Dubey
  • 5,067
  • 7
  • 30
  • 51

1 Answers1

1

I suspect you may need to set the 'options' of json_decode to use JSON_BIGINT_AS_STRING. Check out http://php.net/manual/en/function.json-decode.php And this post led me to the possible solution PHP JSON large integers