Facebook OpenGraph: Use a facebook post URL as the canonical URL - php

I'm working on a service which can share url's to different social networks such as Facebook but I've run into some issues with how Facebook deals with it's own posts and content.
I've a page on my url, my-domain.com/share/u?URL where the URL parameter will be crawled and correct meta-tags and opengraph tags will be added to the page which then can be crawled by e.g. Facebook.
However, if I have a Facebook post URL (e.g. https://www.facebook.com/smashmag/posts/10154297276027490) and add this to my og:url meta-tag, facebook graph debugger reports it as a bug and when I try to share the custom url, it will not fetch or create a preview of it.
If I directly use the facebook share url with the post there are no issues (https://www.facebook.com/sharer/sharer.php?u=https://www.facebook.com/smashmag/posts/10154297276027490)
Is there any way to get around this or make facebook treat it's own URLs and posts as a valid og:url tag?
On my own service, I crawl facebook pages as well and here I can fetch the URL and create an embed post so this is not where the problem lies. It is simply when I want to share a custom URL on facebook, which actually is a redirect URL to a Facebook post URL.
Please let me know if I've explained myself unclear and I'll try to elaborate.

Related

Share video on a page on facebook

I want to share a video from my site on a page on facebook, not on my profile.
For Eg: I want to share video on https://www.facebook.com/pages/Opticians/108277472608071
I have a button as post to wall. On clicking it the video should get uploaded on the above mentioned page. I searched a lot for this but I ended in getting only share button which shares the post/video to our profile. How can i share that video on a different page on facebook?
Any Help would be greatly appreciated.
The reference page for this API can be found here. And here is a Facebook Developers blog post related to your problem.
According to this resources Facebook provides graph-video.facebook.com endpoint, that can be used to upload a video to user's wall. You need to perform HTTP POST request to this endpoint passing video file in file POST parameter.

How do you share a link, that have POST data?

I am building a website and I am going to add the possibility to share on Facebook, Twitter and Google +. How ever, in some of the sharing codes I have to pass the URL I want to share in a href, the Facebook one gets automatically the actual URL of the page.
My question is: this pages I'm sharing have post data, will the Facebook one work? And what can I do with the other ones that I have to do an href? Is this possible with pages that have post data? If not, what can I do?
Thank you.
You can't. Links can only include plain URLs and make GET requests.
That said, if you want to share a page on social media, it almost certainly isn't appropriate to be requiring a POST request to generate that page in the first place.

PHP SDK - Post Image to facebook fan page

I have a file url (http://example.com/image.jpg) and I need to make an image post to a facebook fan page (already have the access token).
What is the best way to do this with the facebook PHP SDK?
It seams like I will need to some how load the image and then some how post it as multipart/form-data according to the api docs
No, you can also use the parameter url with the publicly reachable HTTP address of your image, instead of the source parameter, and send it as a normal POST request. (Mentioned here in last sentence of introduction: developers.facebook.com/docs/reference/api/photo)
That seems to be info for postings to a users wall not a fan page. The docs differ fan pages.
It works for pages as well. And #filepath is for real HTTP POST uploads using cURL (explicitly or implicitly by using the FB PHP SDK). With the url parameter you just pass the value http://example.com/image.jpg, nothing else. (Apart from message, title, …)

Link to Facebook Fanpage Iframe

I have a problem with my fanpage. A gallery script is running a my webspace and i put it in the app also in th iframe of the Fanpage. The gallery script has get an Share button to post the photos on facebook. This part of it is running fine but when i clicked the link that was posted in Facebook i had been reffered to my page on my webspace and not to the iframe with the webpage and the photo. Is it possible to edit the link to go to this page in facebook iframe?
This is not a problem in general. You can try to redirect your website into the Facebook tab application my checking the HTTP_REFERRER and the url. You might have a look at this example
There is an URL you can try to call and see if you get redirected to the right application. Additionally, you can add app_data-parameters to the URL to identify the real target into your app.
All that can be done by the following code:
// set the target facebook page name and id to perform a forceRedirectToTab()
$tmpFbHelper
->setPageName($iniHandler->getIniSetting('facebook.'.fbHelper::getAppNamespace().'.page.name'))
->setPageId($iniHandler->getIniSetting('facebook.'.fbHelper::getAppNamespace().'.page.id'))
->setSecret($iniHandler->getIniSetting('facebook.'.fbHelper::getAppNamespace().'.secret'));
// perform a redirect to the facebook tab application if someone opens the url out of facebook
// the facebook-linter is not affected by this :)
$tmpFbHelper->forceRedirectToTab();
// perform a deeplink if for example a special url is called or you identify some app-data
$tmpFbHelper->performDeeplink();
You will have to look at your published links into the stream so that the PHP-code finds out that you will redirect and deeplink!
I hope this ideas might help you :)

Facebook social features on iframe app

We are developing a facebook iframe application that pulls some images (via an API) to the current user album (creates a new one).
The user views his newly uploaded album photos using a facebook lightbox clone. In this clone he must be able to comment and like the current viewed photo.
Is there a way to provide facebook comments & like to these pictures without the use of the Graph API (which would require us to replicate a lot of visuals).
Another try was the social plug-ins with the facebook photo url given but no success.
Any ideas?
I would recommend using the social plugins that facebook provide.
For the likes and comments you can specify a URL in the plugin code, that URL should be the URL of the photo relative to your app e.g. http://myapp.com/photo/123 and not the http://app.facebook.com address.
Facebook will need to be able to crawl that URL so if you are checking if the user is logged in via PHP then you should either disable this if the user agent contains facebookexternalhit or show a different page for that user agent. It doesn't matter about the content, just set a couple of og: meta tags and that should be fine.

Categories