Posts tagged with facebook-graph-api

I have developed a Facebook app using Facebook Login for Business where the logged in user can allow the app to retrieve a list of pages the logged in user manages. To get permission for pages_show_list feature, I had to add 'Facebook Login for Business' product to the app and the request got approved by the Facebook App Review team.

However now when I try to login to the Facebook app from a user (that is not listed in the app's user roles) I get "It looks like this app isn't available" soon after the login in the popup. The app is Live but still I get that error. I am trying to implement the same functionality as Senja.io does and they do the same thing and anybody whether they manage pages or not, a business owner or not they can still login and the page selection screen is presented to them. But in my app after someone logs in it shows "It looks like this app isn't available".

I referred the following question on StackOverflow but I couldn't get a proper solution from it. "It looks like this app isn't available" Facebook App Login Error

I have created a separate configuration under Facebook Login for Business and included it in the Facebook login JS code, but there is still no luck with it.

Configuration setting:

Login variation: General

Access token: System-user access token (I used User access token as well but no luck)

Choose token expiration: 60 days

Assets: Pages - Asset required

Permissions: pages_show_list, pages_read_engagement, pages_read_user_content

HTML:

<button onclick="login()">Login with Facebook</button> 

JS:

window.fbAsyncInit = function() {   FB.init({     appId      : '48XXXXXXXXXXX57',     cookie     : true,     xfbml      : true,     version    : 'v20.0'   });   FB.AppEvents.logPageView();    }; (function(d, s, id){   var js, fjs = d.getElementsByTagName(s)[0];   if (d.getElementById(id)) {return;}   js = d.createElement(s); js.id = id;   js.src = "https://connect.facebook.net/en_US/sdk.js";   fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk')); function login() {   FB.login(     function(response) {         if (response.authResponse) {           console.log('Welcome! Fetching your information.... ');           FB.api('/me', function(response) {             console.log('Good to see you, ' + response.name + '.');             getManagedPages();           });         } else {           console.log('User cancelled login or did not fully authorize.');         }       },        {       config_id: '81XXXXXXXXXXX93',       scope: 'pages_show_list, pages_read_engagement, pages_read_user_content'    }); } 

The error I get presented is "app being not available". Is there a way to publish the app? I have been struggling with this for over a month now and I cannot find a solution. Only the app's Admins, Developers, Testers can get through the login step and choose pages. Please help.

I'm attempting to use Meta's OAuth login for a project, however, the dialog is always a complex multi-step process. Several other sites have a simple, 1-click dialog. I noticed that whether I use the SDK or url, it ends up being the same result. Additionally, the url for the 1-click dialog is much longer and always starts with "https://www.facebook.com/privacy/consent/gdp/?params%5Bapp_id%".

1-click Dialog Multi-step Dialog

Ss there any way to get the simpler login dialog on my end, or is it up to Meta?

I tried using both the SDK and a manual login with differing login settings. I also tried adding and removing scopes as well as all the possible auth_types to no avail. I also am testing in live mode/production.

I'm integrating Facebook Business Login using the Facebook JS SDK. Despite following many tutorials and the official guide, I've encountered a persistent issue over the past few days. I believe this might be an edge case specific to my setup.

The problem

Both FB.getLoginStatus() and FB.login() call functions return below response.

{authResponse: null, status: 'unknown'}  

I'm certain I've logged into Facebook and it should show "connected" instead. The issue is that callback functions are being triggered before Facebook returns the response. For example, when FB.login() opens the login dialog, the console shows the callback response before login completion. Additionally, after completing the login, the callback function is no longer called. Here is a screenshot:

Here is the source code

(I just copy-pasted from Facebook Offical Guide)

    <!DOCTYPE html> <html> <head> <title>Facebook Login JavaScript Example</title> <meta charset="UTF-8"> </head> <body> <script>   function statusChangeCallback(response) {  // Called with the results from FB.getLoginStatus().     console.log('statusChangeCallback');     console.log(response);                   // The current login status of the person.     if (response.status === 'connected') {   // Logged into your webpage and Facebook.       testAPI();       } else {                                 // Not logged into your webpage or we are unable to tell.       console.log( 'Please log ' +         'into this webpage.');         FB.login((response) => {           console.log(response)         },{             "config_id":{{FACEBOOK_CONFIG_ID}}         })     }   }   function checkLoginState() {               // Called when a person is finished with the Login Button.     FB.getLoginStatus(function(response) {   // See the onlogin handler       statusChangeCallback(response);     });   }   window.fbAsyncInit = function() {     FB.init({       appId      : '{{FACEBOOK_APP_ID}}',       cookie     : true,                     // Enable cookies to allow the server to access the session.       xfbml      : true,                     // Parse social plugins on this webpage.       version    : 'v20.0'           // Use this Graph API version for this call.     });     FB.getLoginStatus(function(response) {   // Called after the JS SDK has been initialized.       statusChangeCallback(response);        // Returns the login status.     });   };     function testAPI() {                      // Testing Graph API after login.  See statusChangeCallback() for when this call is made.     console.log('Welcome!  Fetching your information.... ');     FB.api('/me', function(response) {       console.log('Successful login for: ' + response.name);       document.getElementById('status').innerHTML =         'Thanks for logging in, ' + response.name + '!';     });   } </script> <!-- The JS SDK Login Button --> <fb:login-button config_id="{{FACEBOOK_CONFIG_ID}}" onlogin="checkLoginState();"> </fb:login-button> <div id="status"> </div> <!-- Load the JS SDK asynchronously --> <script async defer crossorigin="anonymous" src="https://connect.facebook.net/en_US/sdk.js"></script> </body> </html> 

My Environment

I use Facebook Business Login so I can ask my clients permission to manage their pages. I've configured User Access Token configuration and included my Config ID in both login button and in FB.login() function. My Business is verified. I'm testing this in localhost. (I have local ssl and I use HTTPS. Also I've deployed this in my live web app where i have https as well and facing the same problem). My App is in Live mode.

Below are some screenshots from my app configs. I'm trying to give lot of details as I beleive this might be specific to my app configurations.

What I've Tried

  1. I've tried both FB.login() and Facebook login Button. (with facebook login button the onlogin callback function never getting called)

  2. I've deleted ALL my cookies and files

  3. I've deployed this in Live web app

UPDATE

There is a fblo_<app_id> cookie, which my research indicates is a Facebook logout cookie, defaulting to a value of "y". When I manually delete this cookie, the status changes to "connected" (sometimes this works and sometimes not.). However, it's not feasible to ask my clients to perform this action on their end. Additionally, the callback functions are still being triggered before the login (reconnect) process is complete. So maybe there might be an issue related to cookies or sessions.

I'm trying to make a bot that replies to facebook comments on my page's livestream. Unfortunately, after a few replies, Facebook send back an error message with code 368 and I can only send more replies after a few seconds. The full message is:

We limit how often you can post, comment or do other things in a given amount of time in order to help protect the community from spam. You can try again later 

The API I'm using is /${page_id}/comments
There seem to be a lot of people got into my issue as well: https://developers.facebook.com/support/bugs/938590201317189

Page access token expires periodically and if it expires, I need to generate a new one manually.

Is it possible if the page access token can be refresh via code?

Here's my code in react typescript:

const PAGE_ACCESS_TOKEN = "EAAcAHP"; const PAGE_ID = "123456"; export const fetchPageFeed = async () => {   try {     // Fetch page profile picture     const pageInfoResponse = await axios.get(       `https://graph.facebook.com/${PAGE_ID}`,       {         params: {           access_token: PAGE_ACCESS_TOKEN,           fields: "picture{url},name,link",          },       }     );     // Fetch page posts     const postsResponse = await axios.get(       `https://graph.facebook.com/${PAGE_ID}/posts`,       {         params: {           access_token: PAGE_ACCESS_TOKEN,           fields:             "id,message,created_time,picture,full_picture,attachments{media_type,media},reactions.summary(total_count),comments.summary(total_count),shares,video_tags,videos{source,description,thumbnails}",         },       }     );     return {       profilePictureUrl: pageInfoResponse.data.picture.data.url,       pageName: pageInfoResponse.data.name,       pageUrl: pageInfoResponse.data.link,        posts: postsResponse.data.data,     };   } catch (error) {     console.error("Error fetching page feed:", error);     return { profilePictureUrl: "", pageName: "", pageUrl: "", posts: [] };    } };