I was working on my Word Press side and got this idea. Instead of implementing a “Like/Fav” feature to determine top articles, I would like to instead count together how many facebook shares, tweets and +1 that article received and once they are all counted together store them in database (with according article), so I can than choose top articles by selecting out ones with most shares, tweets and +1’s. I would also need to update database every time user clicks on either of the facebook, twitter or g+ buttons.
Is this achievable within Word Press and by use of their api’s?
This is not as simple as it looks like.
There is a great gist on GitHub with all the APIs you want to implement: Get the share counts from various APIs.
You can connect to these servers and fetch data using jQuery and AJAX:
Then, you can replace
// do something with it
lines with another AJAX request to your blog. You will need to write a plugin to handle this request and save the data in the $wpdb. The plugin is relatively simple:When you have your plugin, we can edit
// do something with it
lines in your JavaScript file:For
how_many_tweets()
it will be:For
how_many_fb_shares()
copy/paste the code fromhow_many_tweets()
and just change:For
how_many_google_pluses()
do the same as with facebook:Then, you have to somehow filter your posts using
$type
and$count
which you have written to your$wpdb
.I have to go now. I’ve provided you with more than just a simple information about connecting to Facebook’s, Twitter’s and Google’s APIs. I hope you will make use of it and achieve what you want to achieve.