将参数传递给 FB Api() 方法时出现问题
我有以下代码来获取我的朋友列表,并返回一些特定字段。
public ActionResult Test()
{
fbApp = new FacebookApp();
authorizer = new CanvasAuthorizer(fbApp);
authorizer.Perms = requiredAppPermissions;
if (fbApp.Session != null)
{
dynamic friendsFields = new ExpandoObject();
friendsFields.fields = "id,name,location,bio,gender,religion,activities";
JsonObject data = fbApp.Get("/me/friends", friendsFields);
ViewData["friends"] = data["data"] as JsonArray;
return View();
}
}
我要求提供 id、姓名、位置、个人简介、性别、宗教、活动字段,但结果并未提交所有这些字段。仅返回 id、name、gender,这让人怀疑有什么问题......如果我尝试使用浏览器获取相同的数据并传递字段,结果将返回所有请求的字段:
URL: https://graph.facebook.com/me/friends?fields=id,name,bio,gender,picture,religion,activities&access_token=...
"data": [
{
"id": "data_data_data",
"name": "data_data_data",
"bio": "data_data_data",
"gender": "data_data_data",
"religion": "data_data_data",
"picture": "data_data_data",
"activities": {
"data": [
{
"name": "data_data_data",
"category": "data_data_data",
"id": "data_data_data",
"created_time": "data_data_data"
}
]
}
},
{
"id": "data_data_data",
"name": "data_data_data",
"bio": "data_data_data",
"gender": "data_data_data",
"picture": "data_data_data"
}
]
}
有人知道这里可能出了什么问题吗?可以是API吗?我使用的是最新版本4.1.1
TIA!
I've the following code that fetches my friends list with some specific fields to be returned.
public ActionResult Test()
{
fbApp = new FacebookApp();
authorizer = new CanvasAuthorizer(fbApp);
authorizer.Perms = requiredAppPermissions;
if (fbApp.Session != null)
{
dynamic friendsFields = new ExpandoObject();
friendsFields.fields = "id,name,location,bio,gender,religion,activities";
JsonObject data = fbApp.Get("/me/friends", friendsFields);
ViewData["friends"] = data["data"] as JsonArray;
return View();
}
}
I'm asking for id,name,location,bio,gender,religion,activities fields, but the result doesn't submit all those fields. Only id,name,gender are returned which makes suspect something is wrong... if i try to get the same data using the browser and passing the fields the result returns all the requested fields:
URL: https://graph.facebook.com/me/friends?fields=id,name,bio,gender,picture,religion,activities&access_token=...
"data": [
{
"id": "data_data_data",
"name": "data_data_data",
"bio": "data_data_data",
"gender": "data_data_data",
"religion": "data_data_data",
"picture": "data_data_data",
"activities": {
"data": [
{
"name": "data_data_data",
"category": "data_data_data",
"id": "data_data_data",
"created_time": "data_data_data"
}
]
}
},
{
"id": "data_data_data",
"name": "data_data_data",
"bio": "data_data_data",
"gender": "data_data_data",
"picture": "data_data_data"
}
]
}
Anyone have any idea what might be wrong here? Can it be the API? I'm using the latest version 4.1.1
TIA!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您必须强制转换 Get 方法的结果或仅动态访问它。这是更正后的代码,也修复了授权。
You have to cast the result of the Get method or just access it dynamically. Here is the corrected code with the authorization fixed as well.