We're running a canvas app that has fully localized og tags. Everything is working well except when users choose to manually copy the facebook app url (apps.facebook.com/mysite) into a post.
When that happens, we want the text in the posted message to be in the user's language. Instead, it's always uses the English text from the og: meta tags.
If I could detect which culture the user came from, I could change those meta tags. However I don't see anything in the request header or parameters that are sent from the scraper to indicate where the user is coming from.
I did see that there's an og:locale:alternate tag I could use to specify other languages the page is available in, but unless I get a second request from Facebook with a locale value I don't see how that benefits me.
How can I ensure the posted title/description is in the user's language?
Must it be done using the Localization section in the Facebook App settings?
If so, is there a way to automate it? Our translation workflow is pretty well established and I don't want to send translators into the facebook app to finish the job.
You most probably need some parameter in the querystring to differentiate the urls.
e.g
http://apps.facebook.com/my_app/en/
or
http://apps.facebook.com/my_app/it/
this parameter will actually set the active language on your app.
And facebook scraper will cache the localized title/ description from the meta tags.
Related
I have a website that supports few languages. Page detects and displays respective language based on browser settings (user can select desired language too).
Now id like to share this website with Facebook share.
According to Fb documentation i need to set a number of meta fields for needed language.
How can i detect a language Facebook is trying to scrape my website for? I was trying to use query`s fb_locale parameter, but it does not seem to pass this one with needed language.
Any ideas?
According to Fb documentation i need to set a number of meta fields for needed language.
This was never available for normal posts/shares in the first place, only for Open Graph stories - and for those it has been removed with API version 2.8, too.
https://developers.facebook.com/docs/apps/changelog#v2_8_deprecations
There is no way any more to do what you want.
I'm working on a photo contest fb app to run in a fan page tab. the user should be able to share the photo in order for others to vote for them.
supposing image link in iframe is http://example.com/image.php?id=1 for particular photo, pressing share will share this link through iframe. which leads up to the host app itself.
what I need is sharing the whole fb app tab page url with http://example.com/image.php?id=1 open in its Iframe.
is that possible in any way?
thanks for help.
So to give the “alternative” to #Lix’ answer, which focuses on canvas apps, here the analog way for page tab apps:
For some reason Facebook decided to do things differently for page tab apps – different than with canvas apps, you can not pass just any GET parameters to your app by appending them to the facebook.com address of your app, but you have to use the app_data parameter for that.
You call/link to your app in the form https://www.facebook.com/YourPage?v=app_1234567890&app_data=foo – and whatever you put as value for the parameter app_data, you will find in the signed_request parameter that Facebook POSTs to your app on initial(!) load into the iframe.
So you parse the signed_request (or let f.e. the PHP SDK do that for you), and then you find the app_data value in there. If you want to pass more than one single value, you can f.e. also put JSON-encoded data there – then you have to decode that again after you read the app_data value from the signed request.
The docs just shortly mention the app_data parameter, but the principle itself is quite simple.
Now, when it comes to sharing those links, I found that when you use an address in the above form, Facebook tends to cut the parameters from the URL, and treat the whole link as just a link to your Facebook page – it shows the page’s picture and description, and does not even pass your page tab app along, let alone the app_data parameter.
I found the most reliable way around this is not to link to your page tab on Facebook directly, but instead to a URL of your own app. When the scraper visits it, you deliver the relevant OG information. And when it’s a real user visiting, you redirect them to your page tab app, passing the data you need via the app_data parameter as described above. Redirecting can either be done server-side (info on how to detect the scraper server-side via its User-Agent header), or client-side via JavaScript (which the scraper does not “speak”).
Sure it is. All you have to do is be able to extract the information from your application canvas URL. If your canvas URL is something like this:
https://apps.facebook.com/ImadBakir
Then you could place some more info in there, like this:
https://apps.facebook.com/ImadBakir?photo_id=123
Users will share that link and now in your application, you can parse that photo_id parameter and make the needed HTML changes to display the correct image inside your iframe as the page and application loads.
With regard to parsing the the URL parameters, assuming you'll be doing it with JavaScript, you can read more about it in this post:
How can I get query string values in JavaScript?
I'm about to implement open graph localised objects.
I have configured the og:locale:alternate meta tags, and, when a Facebook crawler request comes in, the correct locale is returned. As a result, I have one object per product (like counter is not divided), and the texts are correctly displayed on the wall posts, according to the user's locale setting.
If I look my own share, I see some Facebook URL parameters appended to the URL, but if someone shares my post, even these parameters are removed, leaving only the canonical URL. The canonical URL however does not contain any locale/language parameters, as these should be defined only by the og:locale tags which is OK for the posts.
But the problem is, that I am unable to find out the current user's locale (the person who actually clicked on the link) from these links.
I'm stuck here, because there's no locale, nor fb_locale parameters in the URL, nor the X-Facebook-locale header is sent. My app runs on an external site (not in canvas or tab) so the PHP SDK's getUser() and getSignedRequest() are not working either. I only have a Facebook cookie named locale.
Shouldn't Facebook append at least a locale/fb_locale parameter to the URL in this case?
Since I only need the locale (which is, I think, completely harmless), I don't want to ask the first-time visitors for their permission to only get their locale. That would be, in fact ridiculous, as they are following a link that they already had in their language.
I don't have any idea to solve this issue.
Thanks in advance if you have any ideas.
My site has a feed system and when user clicks on any one of those feed snippets (the object), I want the action to be publish in their Facebook news feed. So I'm really confused on how to go about it because as far as I'm aware this is how you post actions on Facebook's JavaScript SDK:
FB.api('/me/namespace:action?object=url','post')
How do you dynamically change the properties of the object? Are there parameters you can send? As far as I'm concerned, Facebook asks you to give pass a URL and it'll grab the <meta> information from that URL?
Am I supposed to perform a GET request with my own server and change the meta tags dynamically. This sounds like more work than it needs to be. For example, what if the feed includes a paragraph of text, it'll be impractical for me to post that as a get request and then urldecode the entire thing.
I'm not sure I totally understand your question, but...
You can dynamically change the tags for facebook og: properties, but you have to do it before the page loads (e.g. using PHP as opposed to javascript). After you send the post using the javascript SDK, facebook crawls the page and looks for the info in the og: meta tags.
We are working on a facebook-app with lots of dynamic pages. As the app is embedded in a tab on a facebook page, the urls contain a get-parameter to address the correct tab/app. We want to implement like- and send-buttons for several pages within our app, but facebook seems to dump all get-parameters from urls within facebook. As the result all like- and send-buttons point to the facebook-page itself instead of the tab.
Does anybody now any workaround? We already tried redirects via an external sefor facebook urls only.rver but facebook seems to evaluate the links on click of the like-/send-button (and seems to follow all sort of redirects).
UPDATE:
Here is an example of a problematic url:
https://www.facebook.com/smartmobil.de?sk=app_171502639574871
UPDATE:
The problem seems to be independant of url get-parameters. It seems that the like-button does not work with any url starting with www.facebook.com
When used in a like-button everything behind the ? will be dumped. This seems to happen for facebook urls only.
Best workaround so far is to point your like buttons at external (non-facebook canvas) urls.
To make this work, you need to do some conditional redirecting to get the user back into your canvas URL. You can either use a client side javascript redirect:
<script>
window.location = 'http://apps.facebook.com/yourcanvasname/foo/bar';
</script>
Or you can do a server side redirect based on the useragent string. Basically, if the useragent contains 'facebookexternalhit' then render a basic HTML page containing OG tags, if not, redirect to the canvas URL.
Doing this means the Facebook sharescraper/linter won't follow any redirects back to the canvas URL, but any user that arrives at your URL will get back to Canvas.
i'm too searching for a solution to control the custom page tab's content through a get parameter (app_data). I still don't have a solution but here at least the reason why all www.facebook.com links are srtiped out of get params. Here at bottom the developer explains why.
Unfortunately I don't think what you are trying to do is possible. Posting a like programmatically requires you to specify a Facebook content ID or alias. This won't work for you because tabs to not seem to have an exposed content ID of their own, and instead use the Page's content ID with an additional parameter which you can't use with the graph.
Liking external links and other content that does not have an ID programmatically is prohibited. With an external URL, the first like of an unrecognised URL creates a new Facebook page for those likes to be represented on (which is the issue I've given up trying to fight), but presumably the presence of your Page's content ID alias (www.facebook.com/smartmobil.de) in the url is making Facebook choose you page rather than creating a new one.
The only suggestion I can think of this late at night is to target an external URL that performs a redirect via Javascript, rather than on the server, but Facebook may be wise to that too and I'm afraid I'm going to bed rather than testing it :)