如何使用 Facebook Graph API 执行 FQL Insights 查询
我尝试使用 Graph API 执行 FQL 查询来获取 Insights 计数器的值,但没有成功。
有谁知道我该怎么做?
我使用“Facebook C# SDK”版本5.4.1,C# 4.0。
如果我使用文档中提供的 C# 示例代码
var fb = new FacebookClient(m_accessToken);
dynamic result = fb.Query("SELECT name, uid FROM user WHERE uid= me()");
,我会收到良好的响应
{"name":"","uid":100002632407830}
使用相同的语法,如果我请求“pages_fans”见解计数器并使用 library 5.4.1,
var fb = new FacebookClient(m_accessToken);
dynamic result = fb.Query("SELECT metric, value FROM insights WHERE object_id=6176018219 AND metric='page_fans' AND end_time=end_time_date('2011-12-31') AND period=period('lifetime')");
我总是收到空响应
{[]}
使用相同的代码,但使用库 5.2.1 我总是收到很好的回复
{[{"metric":"page_fans","value":"125535"}]}
这与此处描述的问题相同:使用库 5.4.1 但使用另一种语法时,FQL 查询出错。
目前,我使用 REST API(使用库 5.2.1)来使用 FQL Insights 查询,但我想迁移到使用 Graph API(使用库 5.4.1)的 FQL Insights 查询,因为 REST API 已弃用。
错误在哪里:
- 在我的语法请求中?
- 在“Facebook C# SDK”库中?
- 在 Facebook 服务器上?
此致。
I try without success to execute a FQL query using Graph API to get the value of Insights counters.
Does anyone know how I can do this?
I use "Facebook C# SDK" version 5.4.1, C# 4.0.
If I use C# sample code provided in the documentation
var fb = new FacebookClient(m_accessToken);
dynamic result = fb.Query("SELECT name, uid FROM user WHERE uid= me()");
I receive a good response
{"name":"","uid":100002632407830}
With the same syntax, If I request "pages_fans" Insights counter and use library 5.4.1
var fb = new FacebookClient(m_accessToken);
dynamic result = fb.Query("SELECT metric, value FROM insights WHERE object_id=6176018219 AND metric='page_fans' AND end_time=end_time_date('2011-12-31') AND period=period('lifetime')");
I receive always an empty response
{[]}
With the same code but with library 5.2.1
I receive always a good response
{[{"metric":"page_fans","value":"125535"}]}
It is the same problem described here : Error with FQL query with library 5.4.1 but with another syntax.
Currently I use FQL Insights queries using REST API (with libary 5.2.1) but I want to migrate to FQL Insights queries using the Graph API (with library 5.4.1) because the REST API is deprecated.
Where is the bug:
- In my syntax request?
- In the "Facebook C# SDK" library?
- On Facebook server?
Best regards.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我使用 Facebook Graph API Explorer 发出请求,
但始终收到空响应。
这是 Facebook 的一个错误。
Facebook 上出现了一个关于它的错误:http://developers.facebook.com/bugs/232510993491615?browse=search_4f08c675cce9d2265724293
I made a request with the Facebook Graph API Explorer
I receive always an empty response.
It is a Facebook's bug.
A bug was created about it on Facebook : http://developers.facebook.com/bugs/232510993491615?browse=search_4f08c675cce9d2265724293
我找到了另一种可靠地检索信息的方法
我找到了另一种检索似乎可靠的见解的方法。
此处找到文档 http://developers.facebook.com/docs/reference/api/insights /。
有更多选项允许格式和周期更改 - 下面的示例。
https://graph.facebook.com/2439131959/insights/application_active_users/[period]?format=json&since=[timestamp]&until=[timestamp]&access_token=[access_token]
周期为日、月、周, 寿命。
时间戳只能是有效的 PST 午夜。
access_token = 可以。
1. 不需要许可的指标没有任何内容。
2. app_id|secret_code 或
3. 您的身份验证令牌授予您访问应用程序或页面的洞察数据(即所有者或洞察用户)的权限。
C# sdk 示例:
FacebookClient fbClient = new FacebookClient([appID], [secret]);
I found another way to retrieving the info which works reliably
I found another way of retrieving insights which seems to be reliable.
documentation found here http://developers.facebook.com/docs/reference/api/insights/.
with more options to allow format and period changes - below example.
https://graph.facebook.com/2439131959/insights/application_active_users/[period]?format=json&since=[timestamp]&until=[timestamp]&access_token=[access_token]
period is day, month, week, lifetime.
timestamp has to be a valid PST midnight only.
access_token = could be.
1. nothing for the metrics that don't need permission.
2. app_id|secret_code or
3. your authentication token granted that you have access to the insight data of the application or pages (ie owner or insight users).
C# sdk example:
FacebookClient fbClient = new FacebookClient([appID], [secret]);
获取访问令牌时,请确保您拥有正确的权限
Make sure you have the correct permissions when you get your Access Token
此问题与 Facebook C# SDK 相关。
您能做的最好的事情可能就是在 codeplex 上提交错误,并将
end_time_date
的用法替换为“以秒为单位的时间”
,将period
替换为“一生”
。This issue related to Facebook C# SDK.
Probably best thing you can do is file a bug on codeplex, and replace usage of
end_time_date
to"time in seconds"
andperiod
to"lifetime"
.