【问题标题】:Example of POST to foursquare API?POST 到foursquare API 的示例?
【发布时间】:2012-12-06 00:34:07
【问题描述】:

我正在尝试添加一个新的签入,但我无法弄清楚 Foursquare 希望如何接收参数。我在正文中尝试了一个 url 编码的字符串:

shout=test&venueId=4a663032f964a5202fc81fe3

我已经在正文中尝试了一个 JSON 字符串(带有 application/json Content-Type 标头):

{"shout":"test","venueId":"4a4a9f71f964a52004ac1fe3"}

但是,我总是得到错误响应:

meta =     {
    code = 400;
    errorDetail = "Must provide parameter venueId";
    errorType = other;
};

POST 到他们的签到/添加端点的正确方法是什么?

【问题讨论】:

  • 我在他们的文档中看到,有时该字段称为 VENUE_ID,有时称为场地 ID。你试过另一个吗?

标签: json api http post foursquare


【解决方案1】:

venueId 必须作为 POST 参数发送。执行此操作的具体方法取决于您使用的库/语言。

例如,要在命令行中使用 CURL,您可以使用

curl https://api.foursquare.com/v2/checkins/add -F venueId=<the id> -F oauth_token=<the token>

【讨论】:

  • 之前 Foursquare 出现了一些愚蠢的问题,现在已经修复。我让另一位开发人员确认了愚蠢和愚蠢的结论。这是一个 post 参数。
【解决方案2】:

我遇到了那个错误。

我的问题的解决方法是包含这样的 HTTP 标头内容类型:Content-Type: application/x-www-form-urlencoded

之后我使用了这样的普通帖子数据:

text="t"&url=xxx&v=20130224

我注意到版本和 url 不能被引用,并且 url 需要进行 HTML 编码。

【讨论】:

    猜你喜欢
    • 2011-11-03
    • 1970-01-01
    • 2023-03-25
    • 1970-01-01
    • 1970-01-01
    • 2012-03-10
    • 2012-03-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多