我使用Python来调用Facebook API。这是一个两部分问题。
让我们从:
开始import facebook
graph = facebook.GraphAPI('token')
criteria = {"whatever I'm passing"}
print graph.request('/search', criteria)
----第1部分----
我无法弄清楚如何将位置搜索参数传递给graph.request()
API v2.2文档将位置描述为:
GET graph.facebook.com
/search?
type=location&
center=37.76,-122.427&
distance=1000
但如果我尝试
criteria = {'q': {'center': '37.76,-122.427'}, 'type': 'location'}
我得到facebook.GraphAPIError: (#12) location search is deprecated for versions v2.0 and higher
,这对我没有任何意义。
如果我尝试:
criteria = {'q': {'center': '37.76,-122.427'}, 'type': 'place'}
返回一个空列表。
----第2部分----
如何一次搜索多个内容?例如,人物搜索看起来像:
criteria = {'q': 'john smith', 'type': 'user'}
这样可以正常工作,但现在我的'q'
参数被名称占用,'type'
被搜索类型占用。如何组合第1部分和第2部分来搜索用户和他/她的位置?