Using the Facebook Graph API to search for an exact string

前端 未结 2 1930
醉梦人生
醉梦人生 2020-12-19 08:12

I want to use the Facebook Graph API to search for exact page matches to \"My String\".

I tried https://graph.facebook.com/search?q=%22My%20String%22&type=page

2条回答
  •  隐瞒了意图╮
    2020-12-19 08:59

    Currently, you can't. It's triaged on the wishlist.

    So, you'll have to wrap the request, in Python :

    import requests
    query = 'My String'
    r = requests.get('https://graph.facebook.com/search?q=%s&type=page' % query)
    result = r.json
    result['data'] = [ item for item in result['data']
                       if query.lower() in item['name'].lower() ]
    print [ item['name'] for item in result['data'] ]
    

    Now you only have exact matches.

提交回复
热议问题