本文介绍了如何使用tumblr api获得tumblr粉丝数量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试这么多方法,但我没有得到任何细节..
i am trying so many ways but i am not getting any details..
var oauth_token = "DojseHuV3PmX6AiDzoK5PCN3OO81FkFdAKwm5b4Gv9WmJMFjZi";
var oauth_token_secret = "bp2r2NU7m4I6CJ6mAeVcZeGSfMDaQZhshnSskk4LarPCaDG2yw";
var oauth_consumer_key = "NwmM3pcR8GeRqdjZ50JRNO7UckxmYMUPH32SAsLsErDfg8kAQ6";
var oauth_consumer_secret = "POlW1lez9HsmLwIW3Pt9SBdvgASxXQuDsT92FeKUJGicDqmMQ8";
var oauth_version = "1.0";
var oauth_signature_method = "HMAC-SHA1";
var oauth_nonce = Convert.ToBase64String(new ASCIIEncoding().GetBytes(
DateTime.Now.Ticks.ToString()));
var timeSpan = DateTime.UtcNow
- new DateTime(1970, 1, 1, 0, 0, 0, 0,
DateTimeKind.Utc);
var oauth_timestamp = Convert.ToInt64(timeSpan.TotalSeconds).ToString();
var resource_url = "https://api.tumblr.com/v2/blog/50watts.tumblr.com/followers";
var status = "Updating status via REST API if this works";
var baseFormat = "oauth_consumer_key={0}&oauth_nonce={1}&oauth_signature_method={2}" +
"&oauth_timestamp={3}&oauth_token={4}&oauth_version={5}&status={6}";
var baseString = string.Format(baseFormat,
oauth_consumer_key,
oauth_nonce,
oauth_signature_method,
oauth_timestamp,
oauth_token,
oauth_version,
Uri.EscapeDataString(status)
);
baseString = string.Concat("POST&", Uri.EscapeDataString(resource_url),
"&", Uri.EscapeDataString(baseString));
var compositeKey = string.Concat(Uri.EscapeDataString(oauth_consumer_secret),
"&", Uri.EscapeDataString(oauth_token_secret));
string oauth_signature;
using (HMACSHA1 hasher = new HMACSHA1(ASCIIEncoding.ASCII.GetBytes(compositeKey)))
{
oauth_signature = Convert.ToBase64String(
hasher.ComputeHash(ASCIIEncoding.ASCII.GetBytes(baseString)));
}
var headerFormat = "OAuth oauth_nonce=\"{0}\", oauth_signature_method=\"{1}\", " +
"oauth_timestamp=\"{2}\", oauth_consumer_key=\"{3}\", " +
"oauth_token=\"{4}\", oauth_signature=\"{5}\", " +
"oauth_version=\"{6}\"";
var authHeader = string.Format(headerFormat,
Uri.EscapeDataString(oauth_nonce),
Uri.EscapeDataString(oauth_signature_method),
Uri.EscapeDataString(oauth_timestamp),
Uri.EscapeDataString(oauth_consumer_key),
Uri.EscapeDataString(oauth_token),
Uri.EscapeDataString(oauth_signature),
Uri.EscapeDataString(oauth_version)
);
var postBody = "status=" + Uri.EscapeDataString(status);
ServicePointManager.Expect100Continue = false;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(resource_url);
request.Headers.Add("Authorization", authHeader);
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
using (Stream stream = request.GetRequestStream())
{
byte[] content = ASCIIEncoding.ASCII.GetBytes(postBody);
stream.Write(content, 0, content.Length);
}
WebResponse response = request.GetResponse();
推荐答案
api.tumblr.com/v2/blog/{base-hostname}/followers
要获得关注者,请阅读我建议的API。它们还有一组已经定义的语言,如果它们没有被使用,你总是可以使用这些 URI来获得JSON 格式的结果。 但是,JavaScript会添加到列表中。
这篇关于如何使用tumblr api获得tumblr粉丝数量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!