【问题标题】:How to get certain data from a page to be recorded into a file using php?如何从页面中获取某些数据以使用 php 记录到文件中?
【发布时间】:2015-07-08 10:06:22
【问题描述】:

我正在使用 Facebook Graph API 来获取网页中某个帖子的覆盖率

它会返回一个包含以下内容的页面:

    {
   "data": [
      {
         "id":"129788793265_10154069879148266/insights/post_impressions_unique/lifetime",
         "name": "post_impressions_unique",
         "period": "lifetime",
         "values": [
            {
               "value": 1627
            }
         ],
         "title": "Lifetime Post Total Reach",
         "description": "Lifetime: The total number of people your Page post was served to. (Unique Users)"
      }
   ],
   "paging": {
      "previous": "https://graph.facebook.com/<postID>/insights/post_impressions_unique/lifetime?access_token=xxxx",
      "next": "https://graph.facebook.com/<postID>/insights/post_impressions_unique/lifetime?access_token=xxxx"
   }
}

我想每 10 分钟将页面中的“值”1627 提取到一个文件中。

我该怎么做?

【问题讨论】:

    标签: php json facebook-graph-api extract


    【解决方案1】:

    您从 API 获得的响应是​​ JSON。所以在 PHP 中你需要一个json_decode() 来提取所需的数据。

    要每 10 分钟运行一次脚本,您可以 setup a cron 或者您可以尝试 Poor mans cron。这是一个简单的example

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-11-08
      • 1970-01-01
      • 2021-08-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-04-01
      相关资源
      最近更新 更多