I'm developing a Facebook app and I need to get the URL of the page where the app is installed to set their share buttons and other params.
Thanks!
Take the page id from the signed request (http://developers.facebook.com/docs/authentication/signed_request/) and then call /PAGEID?fields=link and pull out the link value. This would be the url.
Related
I have created a Facebook Application which will be used as a Facebook Tab Page. My problem is that I am unable to get the page id.
I want to use this single application for multiple Facebook Page Tabs but the content will vary based on the Page Id.
The code I am trying to use to get the signed_request is using the JavaScript SDK.
FB.getLoginStatus(function(response) {
console.log(response);
})
This can be done with the signed_request parameter, which is passed on to your URL.
The easiest solution is to use the PHP SDK. It offers a function called "getSignedRequest": https://developers.facebook.com/docs/reference/php/facebook-getSignedRequest
Those are the fields of the signed_request parameter: https://developers.facebook.com/docs/reference/login/signed-request
If you donĀ“t want to use the PHP, you need to parse the parameter on your own. Check out this link for more information and search for "Parsing the Signed Request": https://developers.facebook.com/docs/facebook-login/using-login-with-games
Edit: you will not get the correct signed_request using the JavaScript SDK. Use PHP (or your server language) for this.
The mistake was that the URL added in the Facebook page tab settings was getting redirected as it did not have a "/"; there was a redirect for SEO added and the URL in the Facebook APP sittings did not have the "/".
So as it was getting redirected Facebook sent the POST variable but we have not handled it. Now it is fixed.
Special thanks to #luschn and #Fran Barbero for all your efforts in this.
Is it possible to post on a page with a url scheme?
I currently have this, fb://profile/325899700848032
But this only opens the page ofcourse. What i mean is something like this
fb://profile/325899700848032/PostMessage/"test message" or ../PostImage/image
Is anything like this possible to do?
Thanks!
To post on facebook page you need to ask first for the famous manage_pages authorization. Once you have it you make a FBRequest on the openGraph for me/accounts which return an array of the current user pages and other application. You parse this json for each page and you pick the token_access and the id. You then set the page token access on your facebook manager and then you can post for example a picture to the page with the "{id}/photos" POST graph request {id} being the page id.
Suppose that I click on a facebook link -- once clicked, the URL is transformed to this:
http://www.facebook.com/l.php?u=http%3A%2F%2Fapple.stackexchange.com%2Fquestions%2F398%2Fhow-do-i-build-apps-to-my-jailbroken-ipad&h=uAQFM5WKt
And then I'm redirected to the URL I thought I was going to. Why does facebook do this?
Facebook keeps track of all the links fired from its website. It saves the url you provided as link.
First it forwards you to a facebook link where it saves the url and then it redirects to the actual url.
This way facebook knows which urls are getting most hits.
FYI, Even google does it.
Now I want to automatic redirect to facebook application's index page after user installing the application to his/her facebook page.
My method is use the href tag as below:
<a href='http://www.facebook.com/add.php?api_key=".$APPID."&pages&perms=publish_stream&page=".$paID."' target='_top'>Add APP</a>
I have tried some ways such as add redirect_uri or next or post_authorize_redirect_url as parameter to the add.php link,but they all redirected to the facebook page or application after installing.
Then how to realize it?
Useful link
http://developers.facebook.com/docs/authentication/
I know that it can redirect after authentication.Such as:
https://www.facebook.com/dialog/oauth?client_id=YOUR_APP_ID&redirect_uri=https://www.facebook.com/connect/login_success.html&response_type=token
But what is after installing?
You could just use the API to add the app to the page?
https://developers.facebook.com/docs/reference/api/page/#tabs
https://www.facebook.com/dialog/oauth?client_id=YOUR_APP_ID&redirect_uri=YOUR_URL
Client ID is your app id
Redirect uri is your callback page
For more you can look at this page
I have a scenario where I have a tab application that will be deployed to various fan pages.
I am looking for a way to get build the redirect url from the signed request so I know which fan page to redirect to once the user has authorized the app.
Most of the examples show this as a static url in the tab app, but in my instance I am not sure which fan page is providing the link to the tab.
Hope that is clear.
Rabbit
In your tab app you get Signed request.
So you have two things you need to build your redirectURL.
1) PageId
2) AppId
based on these two values and facebook vanity URL you can create redirectURL as follows:
https://www.facebook.com/profile.php?id=PAGEID_HERE&sk=app_APPID_HERE
replace PAGEID_HERE with pageid and replace APPID_HERE with AppId and you are done.
you can set this URL as ReturnURL property of you app.
app.returnURL= Path generated above.
if(app.autherize) or whatever
I hope this will help.
Regards
Ims