ExpandoObject() 成员和 FB Graph API 链接背后的逻辑
今天刚开始使用 Facebook SDK 的一些开发人员,我无法弄清楚将 Expando 对象的成员链接到下面示例中的 Graph API 对象中的字段的逻辑,该示例取自 facebook C# SDK 文档:
public ActionResult RestFacebookPage()
{
FacebookApp app = new FacebookApp();
dynamic parameters = new ExpandoObject();
parameters.page_ids = "85158793417";
parameters.method = "pages.getInfo";
parameters.fields = "name";
dynamic result = app.Api(parameters);
return View("FacebookPage", result);
}
我确实明白page_ids 和字段,但不是pages.getInfo。如果有人能在这里启发我并告诉我在文档中的哪里可以找到引导我找到此内容的参考文献,那就太好了......
非常感谢!
Just started today some dev using Facebook SDK and i can't figure out the logic followed to link the members of the expando object to the fields in the Graph API objects in the example bellow that was taken from facebook C# SDK docs:
public ActionResult RestFacebookPage()
{
FacebookApp app = new FacebookApp();
dynamic parameters = new ExpandoObject();
parameters.page_ids = "85158793417";
parameters.method = "pages.getInfo";
parameters.fields = "name";
dynamic result = app.Api(parameters);
return View("FacebookPage", result);
}
I do understand the page_ids and fields, but not pages.getInfo. It would be great if someone could enlighten me here and tell me where in the documentation i can find a reference that leads me to this....
Thanks a lot!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不确定我明白你在问什么,但在他们的 项目页面。那么你可以直接查找facebook官方开发者文档。
如果您想问更多“这是如何实现的”类型的问题,我认为最好的方法是在包含 app.Api 的行处进行中断,然后从那里单步执行代码。在 Api 方法中,会检查参数字典是否包含关键“方法”。如果有,sdk 会认为该调用是绑定到旧的 Rest api,而不是图 api。在下面的几个堆栈帧中,我们找到了生成 url 的代码:
您可能应该亲自进入此方法以查看变量保存的内容,并且它应该对您有意义。源码永远是最好的文档。希望这有帮助。
Not sure I understand what you are asking but there is a pretty decent example about translating php to facebook-c#-sdk over on their project page. Then you can just look up the official facebook developer documentation directly.
If you were asking more off a "how is this implemented" type of question, the best way to do this in my opinion is to break at the line containing app.Api and from there just step through the code. In the Api method there is a check to see if the parameters dictionary contains a key "method". If there is, the sdk figures the call is bound for the old rest api, not the graph api. A few stack frames lower we find the code that makes the url:
You should probably step into this method yourself to see what the variables hold and it should make sense to you. The source is always the best documentation. Hope this helps.