Handling big user IDs returned by FQL in PHP

后端 未结 6 2194
时光说笑
时光说笑 2020-11-29 09:30

I\'m using FQL to retrieve a list of users from Facebook. For consistency I get the result as JSON. This causes a problem - since the returned JSON encodes the user IDs as n

6条回答
  •  感情败类
    2020-11-29 09:46

    I use this and it works almost great.

    json_decode(preg_replace('/("\w+"):(\d+)/', '\\1:"\\2"', $jsonString), true)
    

    The json breaks when there is geo data included, eg. {"lat":54.2341} results in "lat":"54".2341

    Solution:

    $json = preg_replace('/("\w+"):(\d+)(.\d+)?/', '\\1:"\\2\\3"', $json);
    

提交回复
热议问题