简体   繁体   中英

c# - Tumblr avatar request

I'm trying to get the url of a tumblr user's avatar . The problem is, what I get back is not the url, but the image itself. This is the link from which I should get the url:

api.tumblr.com/v2/blog/{blog-identifier}/avatar[/size]

This is how I tried to get the url of the avatar. Note : "item" here is a blog (eg: blog.tumblr.com)

WebRequest req = WebRequest.Create("http://api.tumblr.com/v2/blog/" + item + "/avatar/");
WebResponse res = req.GetResponse();
StreamReader rd = new StreamReader(res.GetResponseStream(),Encoding.ASCII);
var end = rd.ReadToEnd();

I read an response on a forum which said :

the /avatar route redirects you to the avatar url.

Don't follow the redirect and pull the url out of the Location header or the body of the request, which contains the same url.

But I don't know how to do that, can you help me ? There are some answers to some similar questions to mine, but those are for a different programming language..

WebRequest req = WebRequest.Create("http://api.tumblr.com/v2/blog/" + item + "/avatar/");
            WebResponse res = req.GetResponse();
            string avatarUrl = res.ResponseUri.ToString();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM