这是我正在使用的代码:
public static void FetchXML()
{
_url = new Uri("http://api.tumblr.com/v2/blog/" + _username + ".tumblr.com/likes?api_key=REc3Z6l4ZYss11a8lX6KKje0X8Hsi9U77SyaPbQrOBBCGJGA6D");
var client = new RestClient();
client.Authority = _url.ToString();
var request = new RestRequest();
request.AddParameter("limit", "20");
request.AddParameter("offset", _offset.ToString());
var response = client.Request(request);
var content = response.Content.ToString();
var parsedResponse = JsonParser.FromJson(content);
}
如果我获取 Uri 值并将其粘贴到浏览器中(使用有效的 Tumblr 用户名),我将获得正确的 JSON,但在我的应用程序中,
response
的内容是:
"{"meta":{"status":401,"msg":"未经授权"},"response":[]}"
有人知道这是为什么吗?根据 Tumblr API 检索点赞只需要我提供的 API 密钥。
您好,您可以使用以下代码来获取回复。
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(URL);
request.Method = "GET";
request.ContentType = "Application/json";
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream receive = response.GetResponseStream();
StreamReader reader = new StreamReader(receive, Encoding.UTF8);
string respond = reader.ReadToEnd();