我试图让使用通常的GET请求https://www.google.com/reader/api/0/stream/contents/feed/ 属于在谷歌阅读器的特定订阅资讯OT = 1253052000&R = N&XT =用户/ - /国家/ com.google /读&N = 20&CK = 1255646178892&客户端=所有MyApplication .
一切似乎都很好,除非URL包含查询字符串,如http://www.aljazeera.com/Services/Rss/?PostingId=2007731105943979989 . 我收到错误,当我检查回复时,我被告知"The requested URL '/reader/api/0/stream/contents/feed/' was not found on this server" . 我知道订阅URL和请求URL的查询字符串混淆了 . 我怎么能绕过这个?
1 回答
您想要Url对Feed Url进行编码 . 有's an encoding in urls that converts any special character into a sequence of characters that won' t干扰查询操作 . 当人们使用空格时你会看到很多,你的浏览器会放置
%20
.在C#我知道找到UrlEncode的地方是HttpUtility.UrlEncode
更新
是的WebUtility.UrlEncode(string url)方法也可以 .
我们的想法是,如果您要将文本插入到网址中,但不希望它影响网址的行为/解析,则需要对要插入的文本进行编码 . 显然,将一个url插入另一个url可能会导致不可取的结果,因此您放入的URL是需要编码的 .
例:
得到的网址将是:
这应该对你有用 .