Answer the question
In order to leave comments, you need to log in
How to display the likes counter of a particular post on your website?
Hello! I really need to get the like count of a particular post from Facebook! I was able to form a request and get the necessary response through the Graph API Explorer, as well as format it all as a link. But I can't do it on my site. I embedded the Facebook JS SDK into the site code, I paste the code from the Graph API Explorer, but nothing happens. How can you display a data counter on your site if there is already a working link for the request and code from the Graph API Explorer? For starters, at least just get the answer in the form of a code.
Here is the code given by Graph API Explorer:
FB.api(
'/10154092833240172',
'GET',
{"fields":"reactions.type(LIKE).summary(total_count).limit(0).as(like),reactions.type(LOVE).summary(total_count).limit(0).as(love),reactions.type(WOW).summary(total_count).limit(0).as(wow),reactions.type(HAHA).summary(total_count).limit(0).as(haha),reactions.type(SAD).summary(total_count).limit(0).as(sad),reactions.type(ANGRY).summary(total_count).limit(0).as(angry)"},
function(response) {
// Insert your code here
}
);
Answer the question
In order to leave comments, you need to log in
Read this section in its entirety https://developers.facebook.com/docs/javascript
Connect the Javascript SDK.
Install the app for yourself and get a user token. Call yours with the received user token.
Remember that code can run in the context of the current user and in the context of the application.
FB.api(
'/10154092833240172',
'GET',
{"fields":"reactions.type(LIKE).summary(total_count).limit(0).as(like),reactions.type(LOVE).summary(total_count).limit(0).as(love),reactions.type(WOW).summary(total_count).limit(0).as(wow),reactions.type(HAHA).summary(total_count).limit(0).as(haha),reactions.type(SAD).summary(total_count).limit(0).as(sad),reactions.type(ANGRY).summary(total_count).limit(0).as(angry)"},
function(response) {
// посмотрите, что приходит в ответе
console.log(response);
// затем используйте любимый способ для интерполяции данных и html
}
);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question