Skip to content

Instantly share code, notes, and snippets.

@pedroadaodev
Created February 15, 2018 18:54
Show Gist options
  • Save pedroadaodev/0df4b5f5b64b28853857cc318d3e68e5 to your computer and use it in GitHub Desktop.
Save pedroadaodev/0df4b5f5b64b28853857cc318d3e68e5 to your computer and use it in GitHub Desktop.
Facebook share count for urls
var url = "https://graph.facebook.com/?ids=http://google.pt,http://www.github.com";"
try
{
string json = string.Empty;
using (WebClient client = new WebClient())
{
json = client.DownloadString(url);
}
if (!string.IsNullOrWhiteSpace(json))
{
var fbCountList = JObject.Parse(json);
foreach (var fbCount in fbCountList)
{
string json1 = fbCount.Value.ToString();
if (string.IsNullOrWhiteSpace(json1))
{
continue;
}
dynamic fbCountObj = JsonConvert.DeserializeObject<dynamic>(json1);
if (fbCountObj == null)
{
continue;
}
string count = fbCountObj.share.share_count;
string urlWithId = fbCountObj.id;
}
}
}
catch (Exception erro)
{
logger.FatalFormat(":: url fb :: {0}{1}", url, urls);
logger.Fatal(erro);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment