How much one URL went viral ? It is based on the shares of that URL on social networking websites. How to get those share counts ?...Here in this tutorial I am going to explain how to get those share count.

Twitter

Get URL
Output
{"count":11,"url":"http:\/\/pojo.sodhanalibrary.com\/"}
Implementation with Java
String url ="https://cdn.api.twitter.com/1/urls/count.json?url=http://pojo.sodhanalibrary.com"; 
URL obj = new URL(url);
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("GET");
//add request header
con.setRequestProperty("User-Agent", USER_AGENT);

// Send request
System.out.println("\nSending 'GET' request to URL : " + url);
BufferedReader in = new BufferedReader(
       new InputStreamReader(con.getInputStream()));
String outputLine;

// reading output from Request
StringBuffer response = new StringBuffer(); 
while ((outputLine = in.readLine()) != null) {
   response.append(outputLine);
}
in.close();

Facebook

Get URL
Output
{
   "id": "http://pojo.sodhanalibrary.com",
   "shares": 27
}
Implementation with Java
String url ="http://graph.facebook.com/?id=http://pojo.sodhanalibrary.com"; 
URL obj = new URL(url);
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("GET");
//add request header
con.setRequestProperty("User-Agent", USER_AGENT);

// Send request
System.out.println("\nSending 'GET' request to URL : " + url);
BufferedReader in = new BufferedReader(
       new InputStreamReader(con.getInputStream()));
String outputLine;

// reading output from Request
StringBuffer response = new StringBuffer(); 
while ((outputLine = in.readLine()) != null) {
   response.append(outputLine);
}
in.close();

System.out.println(response.toString());

Pinterest

Get URL
Output
receiveCount({"url":"http://pojo.sodhanalibrary.com","count":0})
Implementation with Java
String url ="http://api.pinterest.com/v1/urls/count.json?url=http://pojo.sodhanalibrary.com"; 
URL obj = new URL(url);
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("GET");
//add request header
con.setRequestProperty("User-Agent", USER_AGENT);

// Send request
System.out.println("\nSending 'GET' request to URL : " + url);
BufferedReader in = new BufferedReader(
       new InputStreamReader(con.getInputStream()));
String outputLine;

// reading output from Request
StringBuffer response = new StringBuffer(); 
while ((outputLine = in.readLine()) != null) {
   response.append(outputLine);
}
in.close();
System.out.println(response.toString());

Linkedin

Get URL
Output
IN.Tags.Share.handleCount({"count":0,"fCnt":"0","fCntPlusOne":"1","url":"http:\/\/pojo.sodhanalibrary.com"});
Implementation with Java
String url ="http://www.linkedin.com/countserv/count/share?url=http://pojo.sodhanalibrary.com"; 
URL obj = new URL(url);
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("GET");
//add request header
con.setRequestProperty("User-Agent", USER_AGENT);

// Send request
System.out.println("\nSending 'GET' request to URL : " + url);
BufferedReader in = new BufferedReader(
       new InputStreamReader(con.getInputStream()));
String outputLine;

// reading output from Request
StringBuffer response = new StringBuffer(); 
while ((outputLine = in.readLine()) != null) {
   response.append(outputLine);
}
in.close();
System.out.println(response.toString());

3 comments:


  1. Excellent Blog! I would like to thank for the efforts you have made in writing this post. I am hoping the same best work from you in the future as well.
    I wanted to thank you for this websites! Thanks for sharing. Great websites!

    Pubg APK

    Pubg mobile APK

    ReplyDelete
  2. Your blogs are great.Are you also searching for nursing pico writing help? we are the best solution for you. We are best known for delivering nursing writing services to students without having to break the bank.

    ReplyDelete
  3. Thank you very much for providing this information! You literally rescued my day! After hours of attempting to get Facebook Loin to function with Java, I got here and found the answer. I hope you can share more post like this one in the future. Anyway, I want to return the favor by sharing this link - https://games.lol/idle-theme-park-tycoon/. Download this game and have fun. And read the details about Games.lol safety here if you want to make sure that the website is secured and free.

    ReplyDelete

Blogroll

Popular Posts