Well, I'm trying to get a parameter on my Facebook's Page Tab. (This page tab opens an app I've built). So I'm trying to do something like "http://www.facebook.com/mypagename/app_156916377306500?tag=iphone" but nothing happens. Anyone knows how to solve that?
It should be clear from the documentation how to use app_data:
app_data is the ONLY query string parameter in a page tab app's URL which is passed through to your app, it's present in the signed_request which is POSTed to your app's page tab URL, and needs to be decrypted with the app secret (though the SDKs take care of this step for you)
See the Page Tab App documentation and the signed_request documentation for more information
Related
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?
how can I embed my app in my facebook page in a way as here:
www.facebook.com/SzkolaSTRAMA?v=app_323694844330149
I have attached the app to my page using the magic url:
http://facebook.com/add.php?api_key=&pages=1&page=
and tried to open somehow the app within using the v parameter, but it seems it is not that. Can someone give me a clue? Thanks.
Now you can add an application to a page in a page tab by going to below mentioned url
https://www.facebook.com/dialog/pagetab?app_id=YOUR_APP_ID&next=YOUR_URL
You need to change "app_id" with your app_id, you can find it in app settings, "Your_url" should be replaced with your application complete url for e.g. "https://www.facebook.com/TestApplication?sk=app_389610254390000"
after changing values press enter, If you are admin of any Facebook page then you will be taken to a screen where you can select the page, after completion of this step your app will be added to page tab.
For further clarification go to this link
https://www.facebook.com/dialog/pagetab?app_id=YOUR_APP_ID&next=YOUR_URL
YOUR_URL should be replaced with your Canvas url.
(The page that is being loaded into iframe on facebook)
APP_ID with id of the Page Tab application.
Explained also here
https://stackoverflow.com/a/10535905/1520297
Trying to work out Authorization within a page tab app. I direct user to the auth dialog which redirects them back to my page tab with "&code=XXXXXXX..." in the url.
However, $code = $_REQUEST["code"];, which always worked on a canvas app, isn't working for me in the page tab app. How do I access my code to proceed with authorization?
Or... Am I unable to access info in the url with PHP?
Apologies if this is a repeat, but in searching all I've found were questions asking how to get the page url for the sake of redirect.
Since its a querystring, try $_GET["code"] or you could try parsing $_SERVER["QUERY_STRING"]
You will not be able to get code passed to URL of your Facebook Page tab this way since only parameter that passed to your Page tab via URL is app_data.
You should use one of:
URL that reside in under your Page Canvas URL to finish auth flow and then redirect user back to Page Tab
Using JS-SDK FB.login method to authorize user.
The Facebook API docs say the parameter, "app_data," should be used to customize tabs within a Facebook Fan Page.
However, when users add our tab to their page, the "app_data" param gets lost every time, meaning the tabs aren't customized per Fan Page as they should be.
For instance, we want this page to get rendered for one client: http://www.facebook.com/apps/application.php?id=198939416792674&sk=app_198939416792674&app_data=15
After the client adds this URL as a tab to his Fan Page, though, the tab URL loses the "app_data" parameter. The page rendered no longer reflects the data specific to this client.
We need the tabs to contain a parameter specific to each Fan Page. We thought "app_data" was the right approach.
Any clues what we're doing wrong?
The best way to do what you trying to achieve is to customise the content based on the page['id'] that is passed to you via a signed request.
i have one problem with facebook landing page. i created facebook landing page through static fbml app but i have one problem with like button, user must like the page before he will navigate to another page.
i want to do same functionality in my landing page,
http://www.facebook.com/BusinessofCinema?v=app_6009294086.
anyone know about this please help me .
thanks inadvance......
At this point you'll probably want to go with iframe based Facebook page tabs instead, now that these have become available and fbml based apps are being phased out. Among other advantages, the signed_request parameter that Facebook sends to an iframe based tab app includes a flag that indicates whether the user is a fan of the page.
Now that iframes are the only way to create new Facebook apps and FBML is being phased out, you need a new way to do it.
When your app URL is loaded, it is passed a signed_request POST parameter. This parameter contains the information you need. However, it is packed and encoded so it requires some manipulation to get the right info out.
First, split the signed_request on the '.' character. The first part is the signature. The second part is the encoded_data
Decode the encoded_data into a JSON string using the URLBase64Decode function equivalent in your server-side programming language
The JSON object contains a node called "page". This contains a node called "liked".
If "liked" is true, the user liked the page and you display the "liked" version of your app. If false, show the "Please like me" version of the site.
The FBML way will continue to work the way you have it live right now, but for anyone building a new Facebook app, this is the way to do.