FQL查询Facebook [英] FQL Query for facebook

查看:94
本文介绍了FQL查询Facebook的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用数组将我所有的朋友作为数组

Iam getting all my friends as an array using

$graph_url = "https://api.facebook.com/method/fql.query?access_token=" . $access_token .
 "&query=SELECT+uid,name,work.position.name+FROM+user+WHERE+uid+IN+
 (SELECT+uid2+FROM+friend+WHERE+uid1+=+me())&format=json";

我想设置一个条件来获取工作位置名称为'dev'的朋友.我曾尝试使用FQL之类的

And I want to put a condition to fetch the friends whose work position's name is 'dev'.I had try with FQL like

$graph_url = "https://api.facebook.com/method/fql.query?access_token=" . $access_token .
 "&query=SELECT+uid,name,work.position.name+FROM+user+WHERE+uid+IN+
(SELECT+uid2+FROM+friend+WHERE+uid1+=+me())+AND+strpos(work.position.name,'dev')>=0&format=json";

但是即使我中的一些人满足条件,它也会导致我出现空数组.有人可以建议我解决此问题的正确方法吗.谢谢!

But it results me empty array even some of them satisfying the condition.Can anyone suggest me the correct way to approach this..Thanks in Advance.

推荐答案

其他一些人也试图做到这一点,请参见

This has been tried to be achieved by several other people as well, see

https://stackoverflow.com/questions/17382739/how-to -use-strpos-in-fql-查询

> https://stackoverflow.com/questions/18115546/strpos-in-fql-query

我假设您不能在包含数组而不是对象(可以通过object.subobject.field引用)的字段上使用strpos().

I assume that you cannot use strpos() on fields which contain an array and not an object (which you can reference via object.subobject.field).

我怀疑的证明":如果您尝试搜索朋友的当前位置(这是用户对象的子对象,而不是数组),那么它将起作用:

"Proof" of my suspicion: If you try to search your friends current locations (which is a subobject of the user object, and not an array), it works:

SELECT uid,name,current_location FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me()) and strpos(current_location.city, 'M') = 0

在这里,我搜索居住在以"M"开头的城市中的所有朋友.

There, I search for all my friends living in a city starting with "M".

最终,如果FQL无法解决您的问题,您还可以在客户端解析结果.

Ultimately, you could also parse the resuls on the client side if FQL cannot solve your problem.

顺便说一句,我认为您应该对FQL查询使用另一个端点:

And, by the way, I think you should use another endpoint for your FQL queries:

http://graph.facebook.com/fql?q=...

这篇关于FQL查询Facebook的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆