Using the Facebook Graph API to search for an exact string

前端 未结 2 1931
醉梦人生
醉梦人生 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:37

    try using Unicode, U+0200 is the space bar, so concatenate "My", U+0200, and "String". No clue if that works.

    0 讨论(0)
  • 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.

    0 讨论(0)
提交回复
热议问题