Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

facebook app in a page tab - How to get callback URL

Tags:

php

facebook

I am a bit of a catch 22 situation here.

When you load your app into a tab and ask for permission you need to send with it a callback url.

The callback url is a bit of a mission because on a page http://www.facebook.com/pages/<PAEG NAME>/<PAGE ID>?sk=app_<APP ID> the only way to get the <PAGE ID> is to get it out of the signed request:

parse_signed_request($_REQUEST['signed_request'], $APPSecret)

which you can only do when the user has given permission. And you need the ID to be able to get the <PAGE NAME>, which basically means I cannot construct the callback url...

Does anyone know of a better way or different way to Ask for permissions immediately as the page loads and then reload the page?

like image 817
ByronVerreyne Avatar asked May 06 '11 14:05

ByronVerreyne


1 Answers

It seems that you are a bit confused, here are some points:

  1. Your callback (redirect) url should be something relative (or identical) to the Tab url you specify in the application settings. Something like:

    http://www.example.com/canvas/tab/index.php
    

    So no need for the page id.

  2. Even if the page id is not needed, you'll still receive it (even without authorization) in the signed_request!
    Read the Facebook documentation related section carefully:

When a user selects your Page Tab, you will received the signed_request parameter with one additional parameter, page. This parameter contains a JSON object with an id (the page id of the current page), admin (if the user is a admin of the page), and liked (if the user has liked the page). As with a Canvas Page, you will not receive all the user information accessible to your app in the signed_request until the user authorizes your app.

So the thing that you'll not receive is the USER ID not the page id which is kind of obvious since the admin "allowed" the application.

Hope this will clear things out for you.

like image 175
ifaour Avatar answered Oct 11 '22 02:10

ifaour