【问题标题】:Stumbleupon API url encoding problemStumbleupon API url 编码问题
【发布时间】:2011-09-26 08:11:47
【问题描述】:

我正在尝试使用 stumbleupon API 来获取有关我网站上项目的信息。

文档:http://www.stumbleupon.com/help/badge-api-documentation/

现在它可以完美运行,除了一些 URL ......

但是 http://lolbin.net/i/fp16jU82/that's-what-beer-is-for.htm 例如在 URL 中有一个 ',这对于 Stumbleupon API 来说是一个问题。

我尝试了各种方法,但总是收到错误页面:

http://www.stumbleupon.com/services/1.01/badge.getinfo?url=http://lolbin.net/i/fp16jU82/that's-what-beer-is-for.html

http://www.stumbleupon.com/services/1.01/badge.getinfo?url=http://lolbin.net/i/fp16jU82/that\'s-what-beer-is-for.html

http://www.stumbleupon.com/services/1.01/badge.getinfo?url=http://lolbin.net/i/fp16jU82/that%27s-what-beer-is-for.html

http://www.stumbleupon.com/services/1.01/badge.getinfo?url=http://lolbin.net/i/fp16jU82/that%252527s-what-beer-is-for.html

该项目在 stumbleupon 数据库中已经有很多视图:http://www.stumbleupon.com/url/lolbin.net/i/fp16jU82/that%252527s-what-beer-is-for.html

我的问题是,如何通过 API 查询这个特定的项目,以便获得有效的返回?

【问题讨论】:

    标签: api url-encoding apprequests


    【解决方案1】:

    它适用于 %2527

    http://www.stumbleupon.com/services/1.01/badge.getinfo?url=http://lolbin.net/i/fp16jU82/that%2527s-what-beer-is-for.html
    

    返回:

    {"result":{"url":"http:\/\/lolbin.net\/i\/fp16jU82\/that%27s-what-beer-is-for.html",
    "in_index":true,"publicid":"Aq9jhK","views":262882,
    "title":"Thats what beer is for - LOLBIN.net","thumbnail":"http:\/\/cdn.stumble-upon.com\/mthumb\/767\/82718767.jpg",
    "thumbnail_b":"http:\/\/cdn.stumble-upon.com\/altbthumb\/767\/82718767.jpg","submit_link":
    "http:\/\/www.stumbleupon.com\/submit?url=http:\/\/lolbin.net\/i\/fp16jU82\/that%27s-what-beer-is-for.html","badge_link":
    "http:\/\/www.stumbleupon.com\/badge?url=http:\/\/lolbin.net\/i\/fp16jU82\/that%27s-what-beer-is-for.html",
    "info_link":"http:\/\/www.stumbleupon.com\/url\/lolbin.net\/i\/fp16jU82\/that%252527s-what-beer-is-for.html"},
    "timestamp":1317025970,"success":true}
    

    正如 Godius 指出的那样,它是一个双重 urlencoding。 ' => %27 => %2527

    【讨论】:

    • 奇怪的是,在您的问题中,您曾尝试对 URL [%27] 进行单编码,并对其进行三重编码 [%252527],但没有对其进行双编码。这总是你尝试的最后一件事。
    猜你喜欢
    • 2011-10-14
    • 2010-11-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-04-02
    • 2016-08-14
    • 2015-12-09
    • 1970-01-01
    相关资源
    最近更新 更多