How to retrieve Facebook post (preview) meta data for linking to external site, such as LinkedIn or Google Plus? - facebook

I'm trying to link to individual Facebook posts and display the post page's meta data, including an image preview, but looking at the FB post page's source, it has none of the usual meta nor open graph tags.
I found that LinkedIn and Google Plus are able to retrieve meta data when you post a link to a facebook post. See below for a LinkedIn example.
How are they doing it!?

I'm not insider of LinkedIn or Google so not sure of it. But there're two ways they can do it:
Analysing the structure of facebook post and fetch the picture/title/content of post from url.
Fetch post id of the post (fbid), and use graph api to query the details of the post from facebook.

What I wanted to do was get the post page's metadata which wasn't appearing when I requested the url from my server using http.
But what I received was Facebook's error page for "Update your browser"
So I added ...
User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:19.0) Gecko/20100101 Firefox/19.0
... to the header. And it worked.

Related

Share a URL that is shareable on Facebook on LinkedIn

I've worked on sharing dynamic content to be shareable on Facebook populating OpenGraph tags, I know LinkedIn uses OpenGraph tags.
To my surprise when I've tried sharing the same url on LinkedIn nothing shows up.
did anyone have such experience?
I've used https://www.linkedin.com/post-inspector/
But no luck, I get '503 Failure' exception.
Is this the new way to share something on LinkedIn? (Below url)
https://learn.microsoft.com/en-us/linkedin/consumer/integrations/self-serve/share-on-linkedin
I've tried inspecting the url with https://www.linkedin.com/post-inspector/
also
https://developers.facebook.com/tools/debug/
Here in facebook I got response for all the og:tags
I've update the URL-rewrite on ISS to allow UserAgent: LinkedInBot, this change allowed to LinkedIn crawler retrieve the og tags to be populated for linked in crawler request.

How to get facebook post permalink

When using Facebook's Open Graph API to get a list of posts, what we get is a post id like XXXX_YYYY which can be converted to facebook.com/XXXX/posts/YYYY
But these links cannot be used with the facebook embed plugin : https://developers.facebook.com/docs/plugins/embedded-posts/
Eg - https://www.facebook.com/permalink.php?story_fbid=229021587215556&id=11239244970&stream_ref=10 works, but https://www.facebook.com/11239244970/posts/229021587215556 doesn't, even when both the URLs load the same post.
How can I fetch the permalink for a post so that it can be used in the embed box.
As answered by 林果皞:
The best way seems to be using facebook's FQL.

Not able to tag pages in Facebook page post through API

I am not able to tag other pages on Facebook Page post through Facebook API. This is working fine when i post on page through login in Facebook.
I had used a no. of requests on graph API Explorer for this with following parameters.
graph.facebook.com/MY_PAGE_ID/feed
Request# 1
message=My message for #[PAGE_ID_TO_BE_TAGGED]
Request# 2
message=My Message for #[{"PAGE_ID"}:"1":{"PAGE_NAME"}]
Request# 3
message=PAGE_NAME this is for you.
message_tags={"0": [{"id": "PAGE_ID","name": "PAGE_NAME","type": "page","offset": 0,"length": LENGTH_OF_PAGE_NAME}]}
Also tagging seems to be working when i post on my profile.
graph.facebook.com/USER_ID/feed
Request Parameters:
message=this is new message.
place=PAGE_ID
tags=USER_ID
I dont know Where i am missing? Is there any functionality like above for Facebook Pages.

Post an OpenGraph action for Like and Comment without using Like and Comments plugin

I am using GraphAPI to send comments and likes to a facebook photo from my site. The problem is I want to post the action to the user's wall, one which should be viewable from their friends' news feeds like "ChrisB liked a link" and "ChrisB commented on a link", where link is the photo's url on facebook. Of course I expect the photo thumb and name and description to appear on the post as well.
I have attempted to use custom OpenGraph actions and objects for these, but og:url won't accept facebook links now (which is odd because it still works for facebook pages). The error I'm getting from the linter is "Facebook urls cannot be crawled".
Is there any way to get the result that I want?
Instead of using a Facebook URL directly, try using bit.ly links or some way of automating the redirection from your site to Facebook. For example, I would use the apache module mod_rewrite to create a page on my website, but have it redirect to Facebook.
E.g. 'fake page' would be domain.com/{photo_id}.jpg, but have mod_rewrite redirect to http://www.facebook.com/photo.php?fbid={photo_id}

Why do app posts to Facebook not show as pasted via my app, despite OK OpenGraph response?

We have an app on Facebook called TouchActive
We provide ways for user to post content to Facebook, either from web (via AddThis) or native Android/iOS app.
When we post from say Android we identify the app and the post appears correctly, showing "... via TouchActive" all fine.
When we post from web, we post a URL that Facebook queries, and we provide an OpenGraph response from our server with all the og: meta tags, including the facebook app_id.
The content appears correctly (it's parsing the OG response OK), but it doesn't show as posted via our app, and the posts don't appear in our Insight statistics for the app.
We are assuming this can be done.
Anyone know what we could be doing wrong in our open graph response that causes this to not work?
I have tried the Facebook debug tool https://developers.facebook.com/tools/debug and it shows the correctly parsed OG response and no errors, only a warning about og:url.
Is og:url recommended or a MUST for this to work?
Andrew: I am also using the same meta tag for my site and it works as expected and the post is attributed to my site. I guess u should specify the og:url meta-tag once and then check. As this url is used on the attributed app's anchor link on fb wall.
If still it has the same issue then we can dig it more to come to solution.
A user manually sharing a link to or liking a web page which has opengraph meta tags (including an App ID) is not the same as posting the content from the app - are you definitely posting the links using the app?
You must post via the API to get the post attributed to your app, regardless of which app is specified on the page's meta tag (which is done primarily for insights and administration purposes)