Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7440717
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:53:45+00:00 2026-05-29T10:53:45+00:00

I am trying to check with my application if one application is installed on

  • 0

I am trying to check with my application if one application is installed on specific fan page and if it is not installed I want to install it..
for some reason i am unable to get the page access tokens.

I am able to get the user access tokens and user id, but the page access token returns “Exception” “Unknown fields: access_token”.

What is wrong here?
I am using this resources:
http://developers.facebook.com/docs/reference/api/page/#tabs
https://developers.facebook.com/docs/authentication/

 <html>
    <head>
    </head>
    <body>
      <div id="fb-root"></div>
      <script>
        window.fbAsyncInit = function() {
          FB.init({
            appId      : '188474844587139',
            status     : true, 
            cookie     : true,
            xfbml      : true,
            oauth      : true,
          });

          FB.getLoginStatus(function(response) {
              if (response.status === 'connected') {
                var uid = response.authResponse.userID;
                var userAccessToken = response.authResponse.accessToken;
                console.log("User Access Token: "+userAccessToken);
                console.log("User ID: "+uid);

                // get page access token
                FB.api('https://graph.facebook.com/'+uid+'/accounts?access_token='+userAccessToken, function(response) {
                  console.log(response);

                    var pageAccessToken = 'Need to get from the response...';

                    // get information if user got this app
                    FB.api("https://graph.facebook.com/102561956524622/tabs/353470634682630?access_token="+pageAccessToken,
                       function(data) {
                         console.log(data);
                     });

                     // install the app
                    var params = {};
                    params['app_id'] = '353470634682630';
                     FB.api('https://graph.facebook.com/102561956524622/tabs'+pageAccessToken, 'post', params, function(response) {
                      if (!response || response.error) {
                        console.log("Error: "+response);
                      } else {
                        console.log("Ok: "+response);
                      }
                    });
                });
              } else if (response.status === 'not_authorized') {
                console.log("the user is logged in to Facebook, but not connected to the app.");
              } else {
                console.log("the user isn't even logged in to Facebook.");
              }
             });
         };

        (function(d){
           var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
           js = d.createElement('script'); js.id = id; js.async = true;
           js.src = "//connect.facebook.net/en_US/all.js";
           d.getElementsByTagName('head')[0].appendChild(js);
         }(document));
      </script>
    </body>
 </html>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T10:53:45+00:00Added an answer on May 29, 2026 at 10:53 am

    I managed to solve this issue if any one care this is the code

    One of reasons it didn’t work was because I used the full address “http://graph.facebook.com…” and as you can see in the code I am using the
    FB.api function which is adding this address automatically.
    Another reason is that I used the user access token to get information about the application instead of the page access token.
    I was also having problem to install the application because I needed to send the page access token as well.

    P.S: Don’t forget that you need manage_pages permission.

      <script>
        window.fbAsyncInit = function() {
          FB.init({
            appId      : '188474844587139',
            status     : true, 
            cookie     : true,
            xfbml      : true,
            oauth      : true,
          });
    
          FB.getLoginStatus(function(response) {
              if (response.status === 'connected') {
                var uid = response.authResponse.userID;
                console.log(response.authResponse);
                var userAccessToken = response.authResponse.accessToken;
                var pageId = '102561956524622';
                var appId = '353470634682630';
                console.log("User Access Token: "+userAccessToken);
                console.log("User ID: "+uid);
    
                // get page access token
                FB.api('/'+pageId+'?fields=access_token='+userAccessToken, function(response) {
                    var pageAccessToken = response.access_token;
    
                    // get information if user got this app
                    FB.api('/'+pageId+'/tabs/'+appId+'?access_token='+pageAccessToken,
                       function(data) {
                         if (data.data.length < 1) {
                             console.log("Not installed, Installing...");
    
                            // install the app
                             var params = {};
                             params['app_id'] = appId;
                             FB.api('/'+pageId+'/tabs?access_token='+pageAccessToken, 'post', params, function(response) {
                                 if (!response || response.error) {
                                    console.log("Error Installing:");
                                    console.log(response);
                                 } else {
                                    console.log("Installed :)");
                                    console.log(response);
                                 }
                            });
                         }
                         else {
                             console.log("Already installed.");
                         }
                     });
                });
              } else if (response.status === 'not_authorized') {
                console.log("the user is logged in to Facebook, but not connected to the app.");
              } else {
                console.log("the user isn't even logged in to Facebook.");
              }
             });
         };
    
    (function(d){
       var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
       js = d.createElement('script'); js.id = id; js.async = true;
       js.src = "//connect.facebook.net/en_US/all.js";
       d.getElementsByTagName('head')[0].appendChild(js);
     }(document));
    

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was trying to run my application and check for some output on the
I'm trying to use check unit testing framework for my C application. But I
I was trying out a simple JSF application, in which I need to check
I'm trying to check in jQuery if a div contains some text, and then
I have an application that is installed per-machine (since it uses a service). One
I have been trying to authenticate my CGI application through 2 drivers, one that
My application sould check its settings at startup and only then start. I'm trying
I have developed an application with mac and for one month now, Im trying
I'm trying to get a PHP 5 application working on IIS7. This application appears
I'm trying to create an application, and in that I'm receiving some contents from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.