Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redirect to page with add page tab dialog

Facebook recently notified they are deprecating support for app profile pages.

Apps created after Dec 10th no longer have the app page option, together with the "add to my page" functionality, and must use the new Add page tab dialog.

After the user selects which page to add the application to, is there any way to redirect the user to the selected page?

Similar functionality existed in the "old" add to page dialog, e.g.
https://www.facebook.com/add.php?api_key=MY_ADD_ID&pages=1

Activating the dialog with a response function seems to bring no result.

`


// Add app to page
function addToPage() {

// calling the API ...
FB.ui({
        method: 'pagetab',
        redirect_uri: 'MY_URL',
    },function(response) {
        alert(response);
    });

}

` So, two questions:
a) Is there any possibility for the app using the dialog to "know" which page was selected?
b) Is there any way to redirect the user to the selected page.

Thx!

like image 600
Yaron Cohen Avatar asked Dec 20 '11 09:12

Yaron Cohen


2 Answers

<script type="text/javascript">
      function addToPage() {

      // calling the API ...
      FB.ui(
        {
            method: 'pagetab'
        },
        function(response) {
            if (response != null && response.tabs_added != null) {

                $.each(response.tabs_added, function(pageid) {
                      alert(pageid);
                });
            }
        }
      );

      }
  </script>

Use above code...you will get page id of pages selected by the user

like image 72
devson Avatar answered Nov 08 '22 22:11

devson


but what if the user has a custom name for its page.

i modify devson.. code a bit

    FB.ui(
    {
        method: 'pagetab',
        redirect_uri: '',
    },
    function(response) {
        if (response != null && response.tabs_added != null) {

            $.each(response.tabs_added, function(pageid) {
                  FB.api(pageid, function(response) {
                  alert('redirect to ' + response.link);
                    });


            });

        }
    }
  );
like image 4
chris_1a3 Avatar answered Nov 08 '22 23:11

chris_1a3