开发者

Querying Facebook Open Graph API with wildcards?

Ok so basically I'd like to be able to query the Facebook Open Graph API with wildcards to build an autocomplete for movies/music/etc.

Something like this works properly: https://graph.facebook.com/search?q=twilight&type=page

But partial matches don't work: https://graph.facebook.com/search?q=twilig&type=page

Putting a % at the end seems to turn up more results, so I think I might be on the right track, but it's s开发者_开发百科till not quite right: https://graph.facebook.com/search?q=twilig%&type=page

I haven't been able to find any documentation on using wildcards. Anyone have any ideas?


You need to use FQL and the strpos function, something like:

SELECT page_id,name 
FROM page 
WHERE strpos(lower(name),"incep") >=0 
AND page_id IN (
    SELECT page_id 
    FROM page_fan 
    WHERE uid=me() 
    AND type="MOVIE"
)

This would return (for me):

[
  {
    "page_id": 91290503700,
    "name": "Inception"
  }
]

As you can see I've used the lower method AND used small letters in my query to make sure that the query will match.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜