POST / /只能在GET之后才能工作 - 错误或设计? [英] POST to /likes only works after GET - bug or by design?

查看:119
本文介绍了POST / /只能在GET之后才能工作 - 错误或设计?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程式具有代表使用者在FB上喜欢某些内容的权限。使用Facebook C#SDK(5.4.1),这里是我写的:

My app has permissions to "like" something on FB on a user's behalf. Using the Facebook C# SDK (5.4.1), here's what I wrote:

Facebook.FacebookClient fb = new Facebook.FacebookClient(AccessToken);
object o = fb.Get("1234567890_12345678901234567/likes");
dynamic parameters = new ExpandoObject();
dynamic success = fb.Post("1234567890_12345678901234567/likes", parameters);

第二行是多余的,创建一个不必要的往返行程,因为我们对其他喜欢在同一个对象上。但是,没有它,fb.Post失败并抛出远程服务器返回错误:(400)不良请求。

The second line is superfluous and creates an unnecessary round-trip, as we're not interested in the other "likes" on the same object. However, without it, fb.Post fails and throws "The remote server returned an error: (400) Bad Request."

这是C#SDK中的一个错误,或图形API中的错误,还是设计错误?

Is this a bug in the C# SDK, or a bug in the graph API, or is it by design?

请注意,可以在没有先前GET的情况下POST /

Note that it's possible to POST to /comments without a previous GET.

推荐答案

是的,应该可以做没有得到的post命令。奇怪的是,像5.4.1一样的代码不需要在POST之前直接进行类似的额外的GET。也许在我应用程序的流程中的其他地方,我已经通过API完成了一些GET。但是,我将调查我的DELETE问题,我遇到的我/权限(http://stackoverflow.com/questions/8598614/facebook-c- sharp-api-return-400-when-deauthorizing-app),看看首先得到我/权限是否有助于解决这个问题。

Yes, it should be possible to do post commands without a get. Strangely enough, my like code with the 5.4.1 does not require the extra GET directly before the POST for doing a like. Maybe somewhere else in my app's flow I've already done some sort of GET via the API. However, I'm going to investigate my DELETE problem with me/permissions that I'm encountering (http://stackoverflow.com/questions/8598614/facebook-c-sharp-api-return-400-when-deauthorizing-app) and see if a get to the me/permissions first will help resolve that issue.

这篇关于POST / /只能在GET之后才能工作 - 错误或设计?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆