我想登录用户的签到以及他签到的地方的类别。
我试图获取用户喜欢和他们的类别,这对我有用 - “/ me / likes?fields = category” 以下是回复的回复:
{
"data": [{
"name": "11 East Street Cafe",
"category": "Restaurant/Cafe",
"id": "94871278677"
},{
"name": "ABC DEF",
"category": "Politician",
"id": "177526890164"
}],
"paging": {
"cursors": {
"before": "NDkyMzg4OTc3NTYyMjk3",
"after": "MTc3NTI2ODkwMTY0"
}
}
}
为了办理登机手续,我尝试了“/ me / feed?with = location& fields = place,story”并返回已签入的地点列表。它返回我:
{
"data": [{
"place": {
"id": "117586118328311",
"name": "Carraba's",
"location": {
"city": "Ellicott City",
"country": "United States",
"latitude": 39.27153726574,
"longitude": -76.800542073324,
"state": "MD",
"zip": "21043"
}
},
"story": "ABC was at Carraba's.",
"id": "1533836476934935_1546360939015822"
}, {
"place": {
"id": "876737405718973",
"name": "Chipotle Mexican Grill",
"location": {
"city": "Baltimore",
"country": "United States",
"latitude": 39.2866707,
"longitude": -76.6196671,
"state": "MD",
"street": "300 W Pratt St",
"zip": "21201"
}
},
"story": "Aadya Extentia was at Chipotle Mexican Grill.",
"id": "1533836476934935_1546360502349199"
}],
"paging": {
"next": "https://graph.facebook.com/v2.5/1533836476934935/feed?fields=place,story&wi…WzlgXDpe8ZCV8kHWcO2aNxlARSpwIZByS9OWkU8VC3nj2E3VoiLkJNpy2ESOI1R7fHIOJQZDZD"
}
}
但它不会返回签到位置的类别。即我想知道它是餐厅,博物馆还是体育馆等。
我该怎么办? 感谢。
答案 0 :(得分:2)
您可以使用Field Expansion执行此操作:
/me/feed?with=location&fields=place{name,category},story
编辑:看起来这只适用于API版本< = 2.4,但不再适用于v2.5。
编辑#2:我提交了一份错误报告,询问是否故意删除,或者是否是错误。 https://developers.facebook.com/bugs/1550467468600884/
答案 1 :(得分:1)
即使 Place 是 Page ,我也无法通过字段扩展成功检索category
字段...
这可以通过批处理请求完成,方法是使用第一个查询的输出作为第二个查询的输入:
curl \
-F 'access_token={USER_ACCESS_TOKEN}' \
-F 'include_headers=false' \
-F 'batch=[{ "method":"GET","name":"get-places","relative_url":"me/feed?with=location&fields=place{id,name,location},story&limit=100", "omit_response_on_success": false },{"method":"GET","relative_url":"?ids={result=get-places:$.data.*.place.id}&fields=id,name,category"}]' \
https://graph.facebook.com
见