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();
Get URL
{
"id": "http://pojo.sodhanalibrary.com",
"shares": 27
}
"id": "http://pojo.sodhanalibrary.com",
"shares": 27
}
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());
Get URL
receiveCount({"url":"http://pojo.sodhanalibrary.com","count":0})
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());
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());
ReplyDeleteExcellent 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