Facebook FQL 返回

发布于 2024-09-12 21:08:20 字数 1122 浏览 6 评论 0原文

我正在尝试使用浏览器进行 facebook fql 查询,我有一个有效的 oauth 令牌(我可以用它进行图形 api 调用)。

这是我尝试过的 url:

https://api.facebook.com/method/fql.query?query=SELECT metric, value FROM insights WHERE object_id=89192912655 AND end_time=1280430050 AND period=86400 AND metric='page_fans'&access_token=?

我还尝试首先通过 sql 编码器运行 fql 查询:

https://api.facebook.com/method/fql.query?query=SELECT%20metric%2C%20value%20FROM%20insights%20WHERE%20object_id%3D89192912655%20AND%20end_time%3D1280430050%20AND%20period%3D86400%20AND%20metric%3D'page_fans'&access_token=?

我尝试了一些其他指标,我也可以通过图形 api 获取指标,所以我知道它们在那里。

我确信我做了一些愚蠢的事情,但我已经被这个问题困扰了一段时间了!每次调用都会返回:

<?xml version="1.0" encoding="UTF-8"?>
<fql_query_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" list="true"/>

也许我的日期有问题,我用它来获取日期:(ruby)

t = Time.now
=> Tue Aug 03 15:00:50 -0400 2010
>> t = t - 5.days
=> Thu Jul 29 15:00:50 -0400 2010
>> t.to_i
=> 1280430050

有什么想法吗?

I am trying to get a facebook fql query to work using the browser, I have a valid oauth token (I can make graph api calls with it).

Here is the url I tried:

https://api.facebook.com/method/fql.query?query=SELECT metric, value FROM insights WHERE object_id=89192912655 AND end_time=1280430050 AND period=86400 AND metric='page_fans'&access_token=?

I also tried running the fql query through a sql encoder first:

https://api.facebook.com/method/fql.query?query=SELECT%20metric%2C%20value%20FROM%20insights%20WHERE%20object_id%3D89192912655%20AND%20end_time%3D1280430050%20AND%20period%3D86400%20AND%20metric%3D'page_fans'&access_token=?

I tried a few other metrics, I can get the metrics via the graph api as well, so I know they are there.

Im sure im doing something dumb, but I have been stumped on this for a while now! Every call just returns this:

<?xml version="1.0" encoding="UTF-8"?>
<fql_query_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" list="true"/>

Maybe my dates are a problem, I used this to get the date: (ruby)

t = Time.now
=> Tue Aug 03 15:00:50 -0400 2010
>> t = t - 5.days
=> Thu Jul 29 15:00:50 -0400 2010
>> t.to_i
=> 1280430050

any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

↘人皮目录ツ 2024-09-19 21:08:20

我们已经确认了这个错误。这是因为 end_time 必须与 PST 中的日期分隔符对齐,以便 Insights 表返回任何数据。为了解决这个问题,我们引入了两个可用于查询见解表的自定义函数:

  1. end_time_date():接受字符串形式的 DATE(例如“2010-08-01”)
  2. period():接受“lifetime”、“day” 、“周”和“月”

例如,您现在可以使用以下方式查询见解表:

SELECT metric, value FROM insights
WHERE object_id = YOUR_APP_ID AND
      metric = 'application_active_users' AND
      end_time = end_time_date('2010-09-01') AND
      period = period('day');

我们将很快记录这些函数,对于给您带来的不便,我们深表歉意!

PS 如果您不想使用 end_time_date() 函数,请确保查询中的 end_time 时间戳与 PST 中的日期分隔符对齐。

谢谢!

Facebook 洞察团队

We have confirmed this bug. This is due to the end_time having to be aligned with day delimiters in PST in order for the Insights table to return any data. To address this issue, we introduced two custom functions you can use to query the insights table:

  1. end_time_date() : accept DATE in string form(e.g. '2010-08-01')
  2. period() : accept 'lifetime', 'day', 'week' and 'month'

For example, you can now query the insights table using:

SELECT metric, value FROM insights
WHERE object_id = YOUR_APP_ID AND
      metric = 'application_active_users' AND
      end_time = end_time_date('2010-09-01') AND
      period = period('day');

We will document about these functions soon, sorry for all the inconvenience!

P.S. If you don't want to use the end_time_date() function, please make sure the end_time timestamp in your query is aligned with day delimiters in PST.

Thanks!

Facebook Insights Team

幻想少年梦 2024-09-19 21:08:20

您看到的响应是空响应,这并不一定意味着没有可用的指标数据。可能导致此问题的一些想法:

  • 您是否使用用户访问令牌?如果是,用户是否拥有该页面?是否为用户/访问令牌授予了“read_insights”扩展权限? “offline_access”怎么样?
  • end_time 需要指定为太平洋时间午夜。
  • 有效期限为 86400、604800、2592000(日、周、月)
  • 查询“page_fan_adds”指标是否会在给定期限内产生有意义的结果?

虽然我没有使用过见解表,但使用 Facebook 的 FQL 教会我不要期待错误消息、错误代码,而是尝试遵循文档(如果有),然后进行试验...

至于日期,请使用今天午夜的 ruby​​ 代码片段如下:

Date.new(2010,9,14).to_time.to_i

我还在 Graph API 文档页面上找到了以下内容:

冒充

您可以通过请求“manage_pages”扩展权限来模拟由您的用户管理的页面。

一旦用户授予您的应用程序“manage_pages”权限,“accounts”连接将为当前用户管理的每个页面生成一个额外的 access_token 属性。这些 access_token 可用于代表页面进行调用。用户授予您的应用程序的权限现在也适用于他们的页面。 (来源

您是否尝试过请求此权限并在 Graph API 中使用 &metadata=1查询以获取每个帐户的访问令牌?

The response you're seeing is an empty response which doesn't necessarily mean there's no metric data available. A few ideas what might cause this:

  • Are you using a user access token? If yes, does the user own the page? Is the 'read_insights' extended permission granted for the user / access token? How about 'offline_access'?
  • end_time needs should be specified as midnight, Pacific Time.
  • Valid periods are 86400, 604800, 2592000 (day, week, month)
  • Does querying 'page_fan_adds' metric yield meaningful results for a given period?

While I haven't worked with the insights table, working with Facebook's FQL taught me not to expect error messages, error codes but try to follow the documentation (if available) and then experiment with it...

As for the date, use the following ruby snippet for midnight, today:

Date.new(2010,9,14).to_time.to_i

I also found the following on the Graph API documentation page:

Impersonation

You can impersonate pages administrated by your users by requesting the "manage_pages" extended permission.

Once a user has granted your application the "manage_pages" permission, the "accounts" connection will yield an additional access_token property for every page administrated by the current user. These access_tokens can be used to make calls on behalf of a page. The permissions granted by a user to your application will now also be applicable to their pages. (source)

Have you tried requesting this permission and use &metadata=1 in a Graph API query to get the access token for each account?

久随 2024-09-19 21:08:20

如果您想知道 Facebook 页面的粉丝数量,请使用类似以下内容:

https://graph.facebook.com/cocacola

响应包含 fan_count 属性。

If you want to know the number of fans a facebook page has, use something like:

https://graph.facebook.com/cocacola

The response contains a fan_count property.

走走停停 2024-09-19 21:08:20

我不确定日期是否正确。你真的想要将日期作为整数吗?
通常 SQL 采用 db 格式的日期,因此要格式化它,您可以使用:

Date.new(2010,9,14).to_s(:db)
(Time.now - 5.days).to_s(:db)
# or even better:
5.days.ago.to_s(:db)

I'm not sure the date is correct. do you really want the date as an integer?
Usually SQL takes dates in db-format, so to format it you'd use:

Date.new(2010,9,14).to_s(:db)
(Time.now - 5.days).to_s(:db)
# or even better:
5.days.ago.to_s(:db)
够运 2024-09-19 21:08:20

如果像我一样,您从另一个 FQL 语句获取此信息后来到这里,那么您的问题不包括 access_token 参数,例如

https://api.facebook.com/method/fql.query?query=SELECT+name+ FROM+user+WHERE+uid+%3D+me()&access_token=...

(可以使用fb.getAccessToken())

If, like me, you came here after getting this from another FQL statement, then your problem is not including the access_token parameter, e.g.

https://api.facebook.com/method/fql.query?query=SELECT+name+FROM+user+WHERE+uid+%3D+me()&access_token=...

(You can use fb.getAccessToken())

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文