social-feed icon indicating copy to clipboard operation
social-feed copied to clipboard

How to add FB comments and likes, Twitter retweets and favorites counts

Open Morphinof opened this issue 7 years ago • 4 comments

This is missing from the plugin but can be added very quickly :

For Twitter pretty easy to get those rts and favs, you have to add the following line to unifyPostData function of the twitter section of the code : post.rts_count = element.retweet_count; post.favs_count = element.favorite_count;

an then refers to it in your template as follow : {{? it.social_network=="twitter"}} <i class="fa fa-retweet" aria-hidden="true"></i> {{=it.rts_count}} <i class="fa fa-heart" aria-hidden="true"></i> {{=it.favs_count}} {{?}}

For Facebook it needs a little more since those data are not fetched from the request url. First you have to change the "fields" var in the getData function of the facebook section : var fields = '?fields=id,from,name,message,created_time,story,description,link,comments.limit(1).summary(true),likes.limit(1).summary(true)';

then you can add those new data to the element in unifyPostData (of the facebook section of course) : post.likes_count = element.likes.summary.total_count; post.comments_count = element.comments.summary.total_count;

finally refers them in your template as follow : {{? it.social_network=="facebook"}} <i class="fa fa-comments" aria-hidden="true"></i> {{=it.comments_count}} <i class="fa fa-heart" aria-hidden="true"></i> {{=it.likes_count}} {{?}} And you're done ! Hope it'll help some of you

Morphinof avatar Aug 01 '17 12:08 Morphinof

you can create a pull request, so is more easy to debug and apply :)

HartLarsson avatar Aug 01 '17 15:08 HartLarsson

I'll try this week, if i don't forget ;)

Morphinof avatar Aug 02 '17 08:08 Morphinof

@Morphinof you tried?

mutiullah7 avatar Aug 29 '17 22:08 mutiullah7

No i didn't i was on some Ruby project, no time ^^

Morphinof avatar Sep 01 '17 18:09 Morphinof