I want to get all the comments made on facebook on a particular link.
see this image: http://cl.ly/062k1T380V1V3y2b1t0G, I want to get all 55 commments for that link. Is there any way I can do it?
I have tried graph.facebook.com/search?q=madhyamam.com, but the output is not accurate, or return null value.
You can get the url by querying all of the url's you have linked from your page:
https://api.facebook.com/method/fql.query?query=SELECT link_id, created_time, title, url FROM link WHERE owner = YOUR_FACEBOOK_PAGE_ID&access_token=YOUR_ACCESS_TOKEN
That should give you a list of your urls and their ids. With the id you should be able to get the comments to it:
https://graph.facebook.com/LINK_ID/comments
That will give you all of the info on your comments.
yoo can easily get mobile number of the user by this url https://graph.facebook.com/me?access_token=ACCESS_TOKEN......
the output comes in json format , after that you got the string , in there is value for key ..."mobile_phone"
Otherwise ,,,it is also beneficial for you https://graph.facebook.com/me?fields=address,mobile_phone&
access_token=ACCESS_TOKEN ...in this case you have to take permissions from the facebook api..
Thanks
Related
I used to get the number of likes for my webpage from facebook with:
http://api.facebook.com/restserver.php?method=links.getStats&format=json&urls=www.example.com
But this doesn't work anymore.
I tried:
https://graph.facebook.com/fql?q=SELECT%20total_count%20FROM%20link_stat%20WHERE%20url=%22www.example.com%22
But this doesn't work either.
I tried:
http://graph.facebook.com/?ids=http%3a%2f%2fwww.example.com
But this gives me only the share_count, not the number of likes.
I found this: https://developers.facebook.com/docs/graph-api/reference/v2.7/object/likes
POST graph.facebook.com/v2.7/{object-id}/likes HTTP/1.1
But I got no idea what the {object-id} is or where I can get it. And I don't know if I need any access-credentials to access the information.
Anyone got a small example what http-requests I need now to get the likes of my webpage please?
receive the number of shares/comments and object-id
graph.facebook.com/?fields=og_object{id},share&id=https://stackoverflow.com/
save shares/comments count
save fb object-id of url
og_object->id
get likes count with (max limit is 1000, then you can use paging):
graph.facebook.com/OBJECT_ID/likes?access_token=ACCESS_TOKEN&pretty=1&limit=1000
UPD 2016-08-22
I found a solution that allows you to get the number of likes/reposts/comments in one step:
https://graph.facebook.com/?fields=og_object{likes.limit(0).summary(true)},share&ids=http://google.com,http://twitter.com
First You need the Id for the page. You can to use the next page. http://findmyfbid.com/ There is you put the link of facebook page that You need for example.
https://www.facebook.com/BooStore1
and the result is:
149955492088239
Now you're going to the api graph of facebook and you need yo use the field "fan_count"
This would look like
**149955492088239?fields=fan_count**
Results:
{
"fan_count": 110,
"id": "149955492088239"
}
Note: first step is optional, You can to use the name in facebook page url that you need.
Hello I am new at facebook graph API
when I used url like this
https://graph.facebook.com/v2.7/me?fields=id,website,about,first_name,last_name,gender,birthday,education,age_range,email,%20television,movies,hometown,context,devices,favorite_teams,work&access_token=EAAM...
I can get website, first name , gender etc of me
but when I try to get another user's information from this url
https://graph.facebook.com/v2.7/{user id}?fields=id,website,about,first_name,last_name,gender,birthday,education,age_range,email,%20television,movies,hometown,context,devices,favorite_teams,work&access_token=EAAM...
I can get null values expect first_name, last_name and id
How can I correct the mistake?
Note : the other user allows to show this info.
Thanks
I recently made a fanpage and i have used embedded code from one of the post of my fanpage to my website.
So now It shows the post on my website and number of likes but i would like to show current existing comments which that particular post had got. Right now it is just displays the comment button and if i will click that then it will take me to the fanpage just for the sake of comment.
So heres what i need
1 - Comment on the embedded post without leaving the website to facebook.
2 - Displaying all the current existed comments ..
the image right now look like this
Thats very simple. First, you need to login user and ask for publish_stream permission. After the user is logged in, you just to display a button that triggers the function named comment, passing the ID (corresponding to the object user is going to comment to) .
You will also need an input field for inserting the comment (of course), and using jquery .value we will get the value of the input field .
PS: Specify NAME and ID on the message input field. I dont remember wich one is, put both of them .
After getting the variables, we will call FB.api, specifing the variables id and comentario than get the response for handling the result (if you want), you can try to reload the comment plugin, or refreshing the page .
function comment(id) {
var id = id;
var comentario = document.getElementById("message").value;
FB.api("/"+id+"/comments","POST",
{
"message": comentario
},
function (response) {
if (response && !response.error) {
alert('Comentado !');
} else {
alert('Erro !');
}
});
$("#atividade").html('COMENTADO');
}
That is very simple and fun, but you will need to get authorization from facebook platform to ask users for publish_stream permissions before production .
I think David's answer will just post a new comment, not show all post's comments.
Unfortunately there is not a option to show the comments on embed posts.
You need to get the post id, call a api to load all comments and so embed each one of them. Yeah, that's terrible...
Open the graph api explorer:
https://developers.facebook.com/tools/explorer/
Type {post-id}/comments on GET input and send it to see a response example.
And that's how you embed comments:
https://developers.facebook.com/docs/plugins/embedded-comments
I don't think loading all comments from all posts will have a good performance. I suggest you to create a button "see comments" which call the api. After that you can create the input text for new comments, like David said.
If i have facebook users photo's URL, for example: https://fbcdn-sphotos-e-a.akamaihd.net/hphotos-ak-ash3/885089_523687507674066_732194510_o.png
Can i retrieve user's name or id which own this photo?
First, fetch the photo_id from the url. For eg:
Link: https://fbcdn-sphotos-e-a.akamaihd.net/hphotos-ak-ash3/885089_523687507674066_732194510_o.png
PhotoId: 523687507674066
Then make the \GET request to this ID. Just like this:
\GET http://graph.facebook.com/523687507674066
(you can validate this link in the browser)
You'll get the JSON response just like-
....
from: {
category: "Recreation/sports website",
name: "Emocje do pełna",
id: "290868840955935"
},
....
So, you just have to fetch the id from the from paramter
Yep https://www.facebook.com/photo.php?fbid=523687507674066 The middle number is the photo id
Late response on this - sorry.
Taking the middle number from the image file name, you can sometimes find the profile it came from.
www.facebookcreep.com has a tool for this. It takes the number and looks up to see if it can locate the profile. I believe the pictures needs to have been shared to public is the downfall though.
Is there a way to retrieve the list of Facebook users that have clicked the like button on an external website?
E.g. there is a domain example.com which has been confirmed via Facebook Insights to belong to fbUser1 (using OG meta tags).
Somewhere on example.com there is a page with multiple XFBL like buttons, each one pointing to a further specific URL on example.com, e.g. example.com/xyz, example.com/abc etc.
What I'd like to get is the list of users that liked example.com/xyz and of those who liked example.com/abc.
My intuitive approach would be to look at graph.facebook.com/123456789/likes (where the number is the ID of the domain taken from FB insights), but this always returns an empty dataset:
{
"data": [
]
}
I've also tried getting an OAuth access token from https://graph.facebook.com/oauth/access_token?type=client_cred&client_id=APPID&client_secret=APPSECRET (where APPID and APPSECRET are taken from a FB application that is marked as owning the domain using OG meta tags), but that makes no difference.
I'd also be interested in a non-OpenGraph (i.e. JS SDK, FQL etc.) solution.
EDIT: Using the following code (according to WideBlade's answer below) still gives me an empty list of likes (the second query never returns):
var objectsQuery = "select id from object_url where url in ('http://example.com/xyz', 'http://example.com/abc', 'http://example.com/123')";
var likesQuery = "select object_id from like where object_id = {0}";
FB.Data.query(objectsQuery).wait(function (objectRows) {
console.log(objectRows);
FB.Array.forEach(objectRows, function (objectRow) {
FB.Data.query(likesQuery, objectRow.object_id).wait(function (likeRows) {
console.log(likeRows);
})
});
});
FQL Should do the trick.
$facebook->api_client->fql_query('SELECT user_id FROM like WHERE object_id="OBJECTID"');
Here is the link.
Some general info about FQL.
FQL is initiated using the JavaScript SDK, in this way.
If you can post some sample code-I can try and give some more specific help.
A note should be made-once you've got the user ID's, you can just query the names and get them in a list.
EDIT: To get the URL of an object you should query this table using fql.
This cannot be done. Facebook does not allow you to query for specific user ID's of people who have liked a certain page. This is because of privacy concerns.
See the disclaimer on this page https://developers.facebook.com/docs/reference/fql/like/