Two distinct graph objects for same URL? - facebook

When I lint a URL through Facebook's Linter / Debugger, it generates a Graph Object structured like [Obj#1] https://graph.facebook.com/380728101301 (I'm using Facebook's IMDB example so it's clear it's not just me). While this object has an id associated with it, this id does not work as a pageId in Graph API functions (pages.isFan for example).
Previously, it was the case that I could access the same Graph Object I had linted by using that object's URL as the id in the Graph. For the IMDB example, that's https://graph.facebook.com/?id=http://www.imdb.com/title/tt0117500/ (this also maps to [Obj#2] graph.facebook.com/114324145263104 if you just swap the id from the result back into the URL).
However, even though it seems like that should be the same graph object as what was linted, it is a different object with a different id. This object's id can be used with the open graph api functions, but the object itself is not actually generated until someone has explicitly liked the URL, which is not particularly convenient.
So not only does the linter no longer seem to generate usable objects on its own, but it also appears that two different objects are being generated by Facebook from the same metadata at the same url. Confusing.
My questions are:
1) What is the difference between these two Graph Objects?
Obj#1 -- graph.facebook.com/380728101301
Obj#2 -- graph.facebook.com/114324145263104
2) Is there still a way to generate an Graph Object with a valid pageId (like Obj#2) before someone has explicitly liked the page the og metadata is on?

https://graph.facebook.com/380728101301 (I'm using Facebook's IMDB
example so it's clear it's not just me). While this object has an id
associated with it, this id does not work as a pageId in Graph API
functions (pages.isFan for example).
pages.isFan is not a graph API function but a legacy REST API method. from pages.isFan doc:
Checks whether a user is a fan of a given Page. Doesn't work for
Application about Pages.
your first id = application about page, that's why it doesn't work.
hope this helps

Related

Facebook Crawler infers different og:url than the one specified in the metatag

I am trying to collect the engagement data for this page: http://www.nature.com/news/the-future-of-dna-sequencing-1.22787
While working on my code I realized that Facebook returns different Open Graph objects for different variations of the URL which should not happen as the page provides a canonical URL.
Example:
http://www.nature.com/news/the-future-of-dna-sequencing-1.22787
http://www.nature.com/news/the-future-of-dna-sequencing-1.22787/
https://www.nature.com/news/the-future-of-dna-sequencing-1.22787
https://www.nature.com/news/the-future-of-dna-sequencing-1.22787/
resolve to different Open Graph objects.
Upon inspection in the Open Graph Object Debugger I saw that the inferred canonical URL had additional parameters, e.g., http://www.nature.com/news/the-future-of-dna-sequencing-1.22787?error=cookies_not_supported&code=4b78fd75-8cad-4456-a877-be0c9c1b9108
While I am aware that the redirects failed because of some cookie action going on, the last part of the new URL code=4b78fd75-8cad-4456-a877-be0c9c1b9108 varies for each of the 4 URL variations, which then leads to different OG objects.
Can somebody help me out here and explain why Facebook is inferring a new canonical URL (with added parameters) even though the original link had provided one?

Is there any API for fetching metadata of article using Facebook Open Graph Object Debugger?

I want to fetch metadata of any web-page using Facebook Open Graph Object Debugger.
We can get it from this URL: Open Graph Object Debugger
Example: Open Graph Object Debugger for Google
It will provide all the information related to that URL. Is there any way to get this information using API(in JSON format)?
Yes, via the API URL Object described here and in even more detail here. Note that you can issue a POST request to this URL to force a refresh. You can even get additional data such as how many times that link was shared on Facebook!
https://graph.facebook.com/v2.10/?fields=og_object&id=http%3A%2F%2Fwww.imdb.com%2Ftitle%2Ftt2015381%2F&access_token={YOUR_TOKEN}
I did experience inconsistencies, namely if the obejct does not exist the API will return nothing but if you query it a few seconds later it will be there. For this reason we could not rely on Facebook and simply fetched the page ourselves and parsed out the og:* tags.
It may be perfect if you don't care about misses and having to re-fetch or if you just want to programmatically clear the Facebook OG cache.
It's wise to post to it every time you create a new page to force the cache or sometimes the first person to paste the URL into Facebook won't get the link preview!
Yes you can use this https://urlmeta.org
Its usage is pretty simple. Just make a GET call and pass the URL to API endpoint: https://api.urlmeta.org and you are done.

Get Share Count of Public Video with FB API v2.5

The Short Version:
"I can visit the public page without being logged into Facebook and see underneath the post is says "2155 shares" I would like to know how to access that number through the API"
The Details:
I'm trying to use the newest version (v2.5) of the graph HTTP API to determine the total share count for a public video. The problem is FB seems to have changed the API enough that older posts on SO no longer answer this question.
Looking at the Graph API Documentation it appears that video nodes now have the "sharedposts" edge. However, calling this route with summary=true only returns a few of the shares and no value for a total count. This returns counts for comments and likes so I'm not using the endpoints incorrectly or messing up my authorization.
I've also tried to use the URL Node but this doesn't seem to do much with links inside of Facebook. I simply get a JSON response with an 'id' field with the same url I supplied as a request parameter. Seems like this route is meant to be used for links to content outside of Facebook.
I've tried the above methods with multiple videos on multiple public pages so I don't think it is due to the group owners restricting access, unless this is the new default.
It seems arbitrary that I would be allowed access to total counts for comments and likes, but not shares. Is there some legacy way to do this or am I out of luck for now?
You should query the Post element containing the Video element.
Each video posted is also contained in a post element.
The post id is then composed of the video id prepended with the posting entities id (user, page etc'), separated with an underscore.
It then looks like: user-id_video-id.
Then using the Graph API to get the share count of a post is straightforward:
GET /v2.5/{post-id}?fields=shares
Example
Lets take a video from the BBC page:
https://www.facebook.com/bbcnews/videos/10153524838517217/
(Please tell me if the link is broken. I'll switch it to something newer :))
Video id : 10153524838517217
Page id (see below): 228735667216
--> Post id: 228735667216_10153524838517217
And the request would be:
GET /v2.5/228735667216_10153524838517217?fields=shares
(open in the Graph API explorer)
Page id
to get the page id, you could query the video element for the from field.
GET /v2.5/10153524838517217?fields=from

Facebook Graph API - Get list of id's and names that have liked a post

Using the Facebook Graph API, how do I get the list of people who have liked a specific item (say a post)? Doing a call like /ITEM_ID/?fields=likes using the Graph Explorer I'm able to see a list of names in the [data] array, but, when I call it from a website it doesn't display the names, it just shows the count value.
I'm thinking it's one of two things, but I'm not sure:
I'm using the wrong access token. I'm using the extended one for the fan page the post is on.
Facebook just doesn't give out that info to someone (or a fan page) that isn't the owner of the original post. (I'm the one who made the post.)
Is there a way to get the list of user names and user id's that have liked a post, and if so, what's required to do so?
There could be 2 reasons-
You access token is not correct. You need the read_stream permission for getting the posts.
You are not parsing the resulted JSON correctly.
/ITEM_ID?fields=likes.fields(id,name)
i have done this like this ( me/feed?fields=likes.fields(id,name) ) and it works

Facebook: common URL format for accessing objects and their comments from a browser

I am trying to figure out whether there is a common format for Facebook URLs that can be used to navigate via a browser to different Facebook object types (e.g. status, video, album, photo, etc) and their comments. I need this for the Facebook application I am developing.
For example, a status object and its comments can be reached via a URL of the form:
http://www.facebook.com/facebookAccountID/posts/facebookStatusID.
For videos: http://www.facebook.com/video/video.php?v=facebookVidoeID
For albums: htp://www.facebook.com/album.php?id=facebookAccountID&aid=albumID
For photos: htp://www.facebook.com/photo.php?fbid=facebookPhotoID
Is there a common URL format for accessing any object (regardless of its type) and its comments, rather than the inconsistent forms above?
The json objects returned by the graph api all have a link property which you can use to direct people to view the object on facebook and post/read comments/likes and view the content.
This is eleven years late, but you can construct a functional url knowing only the postID (from the API) by prefacing it with facebook.com/, so that the final url is in this form:
facebook.com/postID
You can also construct it if you have the handle or brandID and the status ID. In the postID, the numbers to the left of the underscore are the brandID, and the numbers to the right are the status ID. Not 100% sure what they call it, and you can't get it out of the API anymore, and it's been deprecated, so you can't call the api with it even if you do have it. But you can still construct the url if you have that instead of the full postID, or you can extract it from the postID if you need to get the url in one of the following formats.
facebook.com/brandID/posts/statusID
facebook.com/handle/posts/statusID
Other than that, you just have to fetch the permalink_url from the api, but I prefer to construct the URLs dynamically so that they are all in a standard format, and so that it is easy to relate a link to a postID.
As of a few weeks ago, the user facing URLs in the browser no longer use this format, but the constructed url will still work.