Anonymous
Anonymous

Reputation: 10216

Different Approach to count Facebook, Twitter, Google+ Shares via jQuery?

I have read this Question and I also have searched on google to get the total number of social media share button's counts but I realize that this is not an easy task especially for Google+ and also if you have multiple buttons for multiple links on a Single Page.

So I'm trying achieve this by using a different approach via jQuery. Link...

enter image description here

I want to get and calculate the total number of shares as text number inside the count box and I have read that jQuery .contents() can access iframe HTML elements, So I want to select the the iframe that generated by the share buttons and select the count's element id and get the total numbers of shares inside a <div>????</div> tag on my webpage. But still no Success...

Please help me to do this & Here is the sample JSFiddle - JSFiddle

Any help would be much appreciated. Thank you! & BTW I'm a beginner & using ASP.NET WebMatrix.

[Edited]

I really need a proper and useful solution to achieve this.

Upvotes: 1

Views: 681

Answers (1)

Tom Maton
Tom Maton

Reputation: 1594

Why don't you just use the API's it would be a whole lot quicker rather than using jQuery's content.

eg http://urls.api.twitter.com/1/urls/count.json?url=http://www.google.co.uk

returns the number of times that url has been shared etc

{"count":92127,"url":"http:\/\/www.google.co.uk\/"}

Facebook and Google have their own api's which you can also check the counts on.

Upvotes: 4

Related Questions