使用 facebook android SDK 的 FQL
我正在尝试使用 facebook android SDK 创建一个 android 应用程序 (http://github.com /facebook/facebook-android-sdk)。我试图弄清楚我是否能够使用此 SDK 来使用 FQL。如果有人有这方面的经验,请告诉我。
显然可以使用 https://api.facebook.com/method/ 来使用 FQL fql.query?query=QUERY,但是 facebook android SDK 似乎不支持这一点。
谢谢;
I'm trying to create an android application using the facebook android SDK (http://github.com/facebook/facebook-android-sdk). I'm trying to figure out if I will be able to use FQL using this SDK. If anyone has any experiences in this regard, please let me know.
FQL can apparently be used using https://api.facebook.com/method/fql.query?query=QUERY, the facebook android SDK however doesn't seem to support this.
Thanks;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这可能是比提到的更好的方法。使用当前版本的 API,您无需手动添加访问令牌或使用 Util.openURL。
This is probably a better way than mentioned. Using the current version of the API you don't need to manually add the access token or use Util.openURL.
以下是使用建议补丁的一些示例代码:
Here is some sample code using the suggested patch:
这是我的解决方案:
您真正需要做的是使用
graphPathRequest
。在android SDK中,已经提供了2个版本,其中之一是快速执行方法。另一种方法是在对此类请求对象调用执行之前发出请求并修改该请求。我的方法使用更高版本。如果您在
FacebookActivity
内,只需致电:希望这会有所帮助。
请注意,我使用的是 AndroidSDK 3.0
Here is my solution:
What you really need to do is using a
graphPathRequest
. Within android SDK, it is already provided 2 versions of it one is quick execute method. Another is to make a request and modify that request before you call execute on such request object. My method use later version.In case you are within
FacebookActivity
, simply call:Hope this helps.
Note that I'm using AndroidSDK 3.0
看起来 Android Facebook SDK 没有对旧 REST api 的参数进行 URL 编码。因此,当您发送大型 FQL 查询时,它无法处理所有空格和特殊字符。我可能会在 github 上发布一个分支来解决这个问题,但与此同时,您可以将 com.facebook.android.Util 中的第 26 行更改为:
注意那里的 URLEncoder 调用。这实际上是该方法的已弃用版本,但目前可以正常工作,当我推送到 github 时,我将包含正确的版本。
It looks like the Android Facebook SDK doesn't URL encode the params for the old REST api. So when you send a big FQL query it can't handle all the spaces and special characters. I'll probably put a fork up on github that fixes this, but in the meantime you can change line 26 in com.facebook.android.Util to:
Notice the URLEncoder call there. That's actually the deprecated version of the method but it will work fine for now, I'll include the correct one when I push to github.