social-feed
social-feed copied to clipboard
How to add FB comments and likes, Twitter retweets and favorites counts
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
you can create a pull request, so is more easy to debug and apply :)
I'll try this week, if i don't forget ;)
@Morphinof you tried?
No i didn't i was on some Ruby project, no time ^^