doushi2902 2015-04-15 18:10
浏览 336
已采纳

使用Facebook Graph Api获取数据

I am trying to get all the facebook group members ids with facebook php sdk, I am getting an array, and can't get out of the array with only ids.

Here is my array:

Array
(
[data] => Array
    (
        [0] => stdClass Object
            (
                [name] => Name Surname
                [administrator] => 
                [id] => 655330041265756
            )

        [1] => stdClass Object
            (
                [name] => Name Surname2
                [administrator] => 
                [id] => 10206563909924840
            )

        [2] => stdClass Object
            (
                [name] => Name Surname3
                [administrator] => 
                [id] => 1035931373098451
            )

I am trying to export only [id], how is this possible?

  • 写回答

1条回答 默认 最新

  • drjtua5953 2015-04-15 18:19
    关注

    Just a simple foreach can be used to iterate through the array and extract the id from each object.

    foreach ($array as $key=>$value) {
        echo $value->id;
    }
    

    Edit: If you want to assign the ids to an array, use the following code:

    foreach ($array as $key=>$value) {
         $idArray[] = $value->id;
    }
    

    Where $idArray is your array of ids.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 做个有关计算的小程序
  • ¥15 MPI读取tif文件无法正常给各进程分配路径
  • ¥15 如何用MATLAB实现以下三个公式(有相互嵌套)
  • ¥30 关于#算法#的问题:运用EViews第九版本进行一系列计量经济学的时间数列数据回归分析预测问题 求各位帮我解答一下
  • ¥15 setInterval 页面闪烁,怎么解决
  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化