Php 从graph api获取故事标记会为标记的事件返回奇怪的id结果

Php 从graph api获取故事标记会为标记的事件返回奇怪的id结果,php,facebook-graph-api,facebook-php-sdk,json,Php,Facebook Graph Api,Facebook Php Sdk,Json,对我来说,最好的解释就是给你看。似乎是64位系统中的float()错误 当我调用/anotherfeed/feed或任何页面时,带有story_标记的帖子会返回一些id作为浮点错误 id中存在浮点错误的示例故事标记。[id]=>1.7153566624E+14 我的问题是,我如何解决这个问题,或者我做错了什么?我所做的就是在foreach语句中循环 if($fvalue[story_tags]){ echo 'Tags: ';

对我来说,最好的解释就是给你看。似乎是64位系统中的float()错误

当我调用
/anotherfeed/feed
或任何页面时,带有story_标记的帖子会返回一些id作为浮点错误

id中存在浮点错误的示例故事标记。
[id]=>1.7153566624E+14

我的问题是,我如何解决这个问题,或者我做错了什么?我所做的就是在foreach语句中循环

        if($fvalue[story_tags]){
                echo 'Tags: ';
                $sTags=$fvalue[story_tags];
            foreach ($sTags as $skey=>$svalue){
            foreach ($svalue as $gkey=>$hvalue){
                $id=$hvalue[id];
                echo ''.$hvalue[name].' '.$id.' ';
                            }
            }
        }



解决方案:

cURL-必须在PHP_EOL中使用数字格式来解决cURL中的问题

//$locs=curl调用/anotherfeed/feed的图形api,仍然需要foreach的解决方案

$locs=json_decode($returned, true);
$stId=number_format($locs[data][1][story_tags][0][0][id], 0, '', '').PHP_EOL;
echo $stId;

PHP-SDK


解决方案是一样的,foreach循环中的长数字需要通过number\u格式运行。

您如何进行API调用?您是否自己执行HTTP请求,然后在其上使用json_解码?如果是这样,请在JSON_decode上将选项JSON_BIGINT_设置为_STRING。到目前为止,仅在php sdk中,在foreach中,我还使用$locs=JSON_decode($returned,true)对graph api进行了cURL;打印(json解码($returned,true));我的示例是,您可以在pageid中输入任何页面用户名进行测试,例如:pageid=facebook pageid=platform pageid=yourpage。我将测试bigint-我希望使用php sdk的解决方案。我没有使用bigint的运气,如果你看看这个示例,数组中的id仍然返回相同的值。//$returned=编码的数组。print_r(json_decode($returned,json_BIGINT_AS_STRING));
Array
(
    [data] => Array
        (
            [0] => Array
                (
                    [id] => 171535666239724_156133294510726
                    [from] => Array
                        (
                            [name] => Another Feed
                            [category] => App page
                            [id] => 171535666239724
                        )

                    [story] => Another Feed shared Non-Profits on Facebook's photo.
                    [story_tags] => Array
                        (
                            [0] => Array
                                (
                                    [0] => Array
                                        (
                                            [id] => 1.7153566624E+14
                                            [name] => Another Feed
                                            [offset] => 0
                                            [length] => 12
                                            [type] => page
                                        )

                                )

                            [20] => Array
                                (
                                    [0] => Array
                                        (
                                            [id] => 41130665917
                                            [name] => Non-Profits on Facebook
                                            [offset] => 20
                                            [length] => 23
                                            [type] => page
                                        )

                                )

                        )

                    [picture] => http://photos-d.ak.fbcdn.net/hphotos-ak-ash3/557037_10150932300320918_1908237167_s.jpg
                    [link] => http://www.facebook.com/photo.php?fbid=10150932300320918&set=a.85612830917.95996.41130665917&type=1
                    [name] => Wall Photos
                    [caption] => Have you heard of the @[159208207468539:274:One Day without Shoes] (ODWS) campaign?  ODWS is an annual initiative by @[8416861761:274:TOMS] to bring awareness around the impact a pair of shoes can have on a child's life.  

During the 2012 campaign, @[20531316728:274:Facebook] drove 20% of traffic to the ODWS microsite and TOMS even launched a Facebook-exclusive "Barefoot & Blue" giveaway with @[25266987484:274:Essie Nail Polish] for the second year in a row.  

We think this is a pretty cool example of creating exclusive content around an important initiative that keeps people engaged and involved!
                    [properties] => Array
                        (
                            [0] => Array
                                (
                                    [name] => By
                                    [text] => Non-Profits on Facebook
                                    [href] => http://www.facebook.com/nonprofits
                                )

                        )

                    [icon] => http://static.ak.fbcdn.net/rsrc.php/v2/yD/r/aS8ecmYRys0.gif
                    [type] => photo
                    [object_id] => 10150932300320918
                    [application] => Array
                        (
                            [name] => Photos
                            [id] => 2305272732
                        )

                    [created_time] => 2012-07-02T17:57:23+0000
                    [updated_time] => 2012-07-02T17:57:23+0000
                    [comments] => Array
                        (
                            [count] => 0
                        )

                )
$locs=json_decode($returned, true);
$stId=number_format($locs[data][1][story_tags][0][0][id], 0, '', '').PHP_EOL;
echo $stId;