int GetTweets(string url) {
string jsonString = new System.Net.WebClient().DownloadString("http://urls.api.twitter.com/1/urls/count.json?url=" + url);
var json = new System.Web.Script.Serialization.JavaScriptSerializer().Deserialize(jsonString);
int count = (int)json["count"];
return count;
}
int GetLikes(string url) {
string jsonString = new System.Net.WebClient().DownloadString("http://graph.facebook.com/?ids=" + url);
var json = new System.Web.Script.Serialization.JavaScriptSerializer().Deserialize(jsonString);
int count = json[url]["shares"];
return count;
}
int GetPlusOnes(string url) {
string googleApiUrl = "https://clients6.google.com/rpc"; //?key=AIzaSyCKSbrvQasunBoV16zDH9R33D88CeLr9gQ";
string postData = @"[{""method"":""pos.plusones.get"",""id"":""p"",""params"":{""nolog"":true,""id"":""" + url + @""",""source"":""widget"",""userId"":""@viewer"",""groupId"":""@self""},""jsonrpc"":""2.0"",""key"":""p"",""apiVersion"":""v1""}]";
System.Net.HttpWebRequest request = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(googleApiUrl);
request.Method = "POST";
request.ContentType = "application/json-rpc";
request.ContentLength = postData.Length;
System.IO.Stream writeStream = request.GetRequestStream();
UTF8Encoding encoding = new UTF8Encoding();
byte[] bytes = encoding.GetBytes(postData);
writeStream.Write(bytes, 0, bytes.Length);
writeStream.Close();
System.Net.HttpWebResponse response = (System.Net.HttpWebResponse)request.GetResponse();
System.IO.Stream responseStream = response.GetResponseStream();
System.IO.StreamReader readStream = new System.IO.StreamReader(responseStream, Encoding.UTF8);
string jsonString = readStream.ReadToEnd();
readStream.Close();
responseStream.Close();
response.Close();
var json = new System.Web.Script.Serialization.JavaScriptSerializer().Deserialize(jsonString);
int count = Int32.Parse(json[0]["result"]["metadata"]["globalCounts"]["count"].ToString().Replace(".0", ""));
return count;}
C# kaynak kodları ile projelerinize yardımcı açık source code örnekleri bulun.Programlama ile uraşan coderlara yardımcı olur.
3 Eylül 2014 Çarşamba
C# LİKE SAYILARI ALMA
Kaydol:
Kayıt Yorumları (Atom)
Hiç yorum yok:
Yorum Gönder