How to set app_data with facebook pagetab dialog url? - facebook

I am trying to set app_data to a specific tab page. So a facebook user who clicks the page tab will have the app_data available.
I was trying to add app_data to the pagetab dialog url
I tried the following urls:
www.facebook.com/dialog/pagetab?app_id=290672084311996&redirect_uri=https://apps.facebook.com/artware/?app_data=aa
www.facebook.com/dialog/pagetab?app_id=290672084311996&next=https://apps.facebook.com/artware/?app_data=a
www.facebook.com/dialog/pagetab?app_id=290672084311996&next=https://jbartfb.herokuapp.com/?app_data=a
www.facebook.com/dialog/pagetab?app_id=290672084311996&redirect_uri=https://jbartfb.herokuapp.com/?app_data=a
none of them worked for me.
thanks,
shai

You redirect URIs may not contain query params. However: When you redirect to a canvas app (look like you do) you can always use rewrite rules to pass params. For example:
https://apps.facebook.com/artware/landing/install/param1/param2
Everything after your base URL (https://apps.facebook.com/artware/) is just appended to the url of your canvas app. So if your canvas URL is https://mydomain.com/myapp/ the previously mentioned landing URL would load https://mydomain.com/myapp/landing/install/param1/param2 inside the IFrame. From there you can redirect the user to whatever URL you like, query params and all.

Related

Facebook tab application without Canvas URL

You know when you create a tab application you have Page Tab section with Page Tab URL: and Secure Page Tab URL:. In my app i want to use FB.init for Fb.login but if I call FB.init i get this error.
Given URL is not allowed by the Application configuration.: One or more of the given URLs is not allowed by the App's settings. It must match the Website URL or Canvas URL, or the domain must be a subdomain of one of the App's domains.
And this is because I dont complete the App on Facebook section from the App configuration, the idea is that i don`t want to complete. What is the alternative?
It might sound counterintuitive, but in your app settings (right near where you set up your Page Tab URLs) you need to open the Website with Facebook Login section and fill in a Site URL. A typical example would be http://mydomain.gov:8080/, but you can include a longer path than / if you want. Also, if you haven't already filled in App Domains, add a domain there to match the Site URL. In my example, it would be mydomain.gov.
The pages that you use the JS SDK on, as well as your redirect_uri in any dialog URLs, needs to begin with the Site URL that you configure.

How to get the direct link to a facebook iFrame url?

I have a app which url is like:
https://www.facebook.com/Foo/app_123456789
this app is running in a iframe and loading some urls of my server. At the start the user see a page like[1]:
www.foo.com/index.php
but in the app you also get pages like[2]:
https://foo.com/foo1/test/Tab/New/12345-6789
now the question:
is it possible to get a link which start with facebook.com/... and directly lead you to the [2] url?
Yes it is possible. You can add an extra variable to your URL like so:
https://www.facebook.com/Foo/app_123456789?app_data=any_string_here
Facebook will then send whatever inside the app_data variable to your iframe inside the singed_request. So all you have to do is to check for its presence (and value) and redirect the user accordingly.

Facebook SDK : Sending Request from Page Tab App

I can send requests to friends using "Multi Friend Request Selector" inside my Page Tab App, which link looks like :
https://www.facebook.com/<my_page_name>/app_<my_app_id>
My friend receives my request, and click "Accept". It forwards to the real link of the Facebook App, which is :
https://apps.facebook.com/<my_app_name>/?fb_source=request&request_ids=<an_request_id>
which is not inside a Page Tab anymore. How can I forward to user to the 1st link instead of the 2nd while the request_ids have to be kept? Do I just make a header('Location: url'); forwarding?
p.s. Timeline is already in use.
Yes you have to forward to your page url, because requests always redirect to the canvas url.
To pass the request ids you can use the app_data field. So instead of redirecting to https://www.facebook.com/<my_page_name>/app_<my_app_id> you redirect to https://www.facebook.com/<my_page_name>/app_<my_app_id>?app_data=requestids. Here requestids are the actual values(the comma separated list that the canvas gets).
app_data is available to your page tab app as part of the signed_request it receives.
From docs:
In addition, your app will also receive a string parameter called app_data as part of signed_request if an app_data parameter was set in the original query string in the URL your tab is loaded on. For the Shop Now link above, that could look like this: "https://www.facebook.com/YourPage?v=app_1234567890&app_data=any_string_here". You can use that to customize the content you render if you control the generation of the link.

Get info from URL in a Page Tab

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.

Link to fan-page with app_data parameter removes the app_data parameter

I have a FB app in an iframe on a Facebook fan-page. If I create a URL linking to that page, and that URL contains an app_data parameter, like this:
https://www.facebook.com/pages/My-Page/123?sk=app_456&app_data=mydata
Then post that in my FB feed, FB strips the app_data parameter, reverting to the canonical URL for the fan page:
https://www.facebook.com/pages/My-Page/123?sk=app_456
Which isn't what I want.
I would consider this a bug, as the state of the application is part of the "canonical" state of the fan page, but for now: Any way to get around this?
I have thought about making the bookmark to my own page:
https://facebook.mysite.com/pages/My-Page/123?sk=app_456&app_data=mydata
and dynamically generate a page with all the OpenGraph tags from the corresponding FB page (to make FB sharing work), and a redirect to the fan page (to get the user to the right place) - but this requires either (a) scraping FB for those OpenGraph tags or (b) accessing the graph.facebook.com api programmatically in a crawl-like fashion, and I don't know what FB thinks of that.
G'Day Leo, might be a bit of a hack but seems to work. I link my app_data onto a separately hosted URL and redirect back to Facebook with it.
So my URL I share is: https://externaldomain.com/deeplinker.aspx?data=stuff
Then response a redirect which is: https://www.facebook.com/[pageurl]?sk=[app]&app_data=[data]
With [data] = stuff