Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/rest/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 从属于URL包含问号(查询字符串)的订阅的Google reader获取提要项?_C#_Rest_Oauth_Google Reader - Fatal编程技术网

C# 从属于URL包含问号(查询字符串)的订阅的Google reader获取提要项?

C# 从属于URL包含问号(查询字符串)的订阅的Google reader获取提要项?,c#,rest,oauth,google-reader,C#,Rest,Oauth,Google Reader,我正试图使用对{FEED URL}?ot=1253052000&r=n&xt=user/-/state/com.Google/read&n=20&ck=1255646178892&client=myApplication的常规get请求获取属于Google reader中特定订阅的提要 除了URL包含一个查询字符串(例如)时,一切似乎都正常。我收到错误,当我检查响应时,我被告知“在此服务器上找不到请求的URL'/reader/api/0/stream/contents/feed/{订阅URL减去

我正试图使用对{FEED URL}?ot=1253052000&r=n&xt=user/-/state/com.Google/read&n=20&ck=1255646178892&client=myApplication的常规get请求获取属于Google reader中特定订阅的提要


除了URL包含一个查询字符串(例如)时,一切似乎都正常。我收到错误,当我检查响应时,我被告知“在此服务器上找不到请求的URL'/reader/api/0/stream/contents/feed/{订阅URL减去查询字符串}”。我知道订阅URL和请求URL的查询字符串不知怎么搞混了。我该如何解决这个问题?

您想对提要Url进行Url编码。URL中有一种编码,可以将任何特殊字符转换为不会干扰查询操作的字符序列。当人们使用空格时,您会经常看到这一点,您的浏览器将放置
%20

在C#中,我知道找到UrlEncode的地方是

更新 是的,这种方法也会奏效

其思想是,当您有要插入url的文本,但不希望它影响url的行为/解析时,您可以对要插入的文本进行编码。显然,将一个url插入另一个url可能会导致不希望的结果,因此您放入{FEED url}的url需要编码

例如:

// The ?, &, and :// will likely cause some interesting parsing by
// the target webserver.
var feedUrl = "http://site.com/url?a=1&b=2";

var serviceUrl = "https://www.google.com/reader/api/0/stream/contents/feed/{0}?ot=1253052000&r=n&xt=user/-state/com.google/read&n=20&ck=1255646178892&client=myApplication";

var resultUrl = string.Format(serviceUrl, WebUtility.UrlEncode(feedUrl));
结果url将是:

https://www.google.com/reader/api/0/stream/contents/feed/http%3A%2F%2Fsite.com%2Furl%3Fa%3D1%26b%3D2?ot=1253052000&r=n&xt=user/-state/com.google/read&n=20&ck=1255646178892&client=myApplication

这对你来说应该很好。

谢谢。在WinRT上,它的WebUtility.UrlEncode(字符串url)。但是我必须为请求编码整个url还是只编码订阅的url?非常感谢!工作得很有魅力!