使用图形api从facebook获取数据

时间:2013-07-24 09:42:29

标签: facebook facebook-graph-api facebook-javascript-sdk

我可以使用facebook api获得所需的数据,例如兴​​趣,电影等。其中包含以下格式。

Array
(
    [data] => Array
        (
            [0] => Array
                (
                    [category] => Movie
                    [name] => 3 Idiots Movie
                    [created_time] => 2012-05-11T13:22:34+0000
                    [id] => 441170255909978
                )

            [1] => Array
                (
                    [category] => Movie
                    [name] => Harry Potter
                    [created_time] => 2011-04-11T05:44:14+0000
                    [id] => 156794164312
                )

            [2] => Array
                (
                    [category] => Movie
                    [name] => Official Narnia: Voyage of the Dawn Treader
                    [created_time] => 2011-03-10T18:26:57+0000
                    [id] => 190647217857
                )

            [3] => Array
                (
                    [category] => Movie general
                    [name] => Harry Porter
                    [created_time] => 2011-03-10T18:26:57+0000
                    [id] => 360697777345
                )

如何获取仅提供电影和ID的详细信息,以便我可以存储在数据库中?

1 个答案:

答案 0 :(得分:1)

您可以采用以下形式:

foreach (Array['data'] as $var)
{
     $ID=$var['id'];
     $Name=$var['name'];
}

注意:Array['data']中,Array将是您要保存此数据的变量的名称。