2011-09-26 33 views
2

我正在嘗試使用stumbleupon API來獲取有關我網站上的項目的信息。Stumbleupon API網址編碼問題

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

現在,它完美的作品,除了一些網址的...

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,所以我得到一個有效的回報?

回答

2

它與%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指出,雙URL編碼。 '=>%27 =>%2527

+0

謝謝。 urlencoding的東西兩次使它的工作。 –

+0

奇怪的是,在你的問題中,你試過對URL ['%27']進行單一編碼,並對它進行三重編碼['%252527'],但不對其進行雙重編碼。這總是你嘗試的最後一件事。 – Cheeso