Posts tagged with facebook-graph-api

I'm setting up the WhatsApp/Meta embedding tool and trying to make it automatically set up everything automatically for programmatic receiving and sending messages to WhatsApp.

The issue I'm facing is that I'm not a valid client code after successful . These are all the steps my application is taking:

Allowing the user to go through the embedding tool At the end, I receive a token from the embedding tool I want to trade it in that token, for an access token but facebook graph api throw an error saying "Malformed access token" or "This authorization code has expired".

     window.addEventListener('message', (event) => {         if (event.origin !== "https://www.facebook.com" && event.origin !== "https://web.facebook.com") {             return;         }         try {             const data = JSON.parse(event.data);             if (data.type === 'WA_EMBEDDED_SIGNUP') {                 // if user finishes the Embedded Signup flow                 if (data.event === 'FINISH') {                     const {                         phone_number_id,                         waba_id                     } = data.data;                     console.log("Phone number ID ", phone_number_id, " WhatsApp business account ID ", waba_id);                     // if user cancels the Embedded Signup flow                 } else if (data.event === 'CANCEL') {                     const {                         current_step                     } = data.data;                     console.warn("Cancel at ", current_step);                     // if user reports an error during the Embedded Signup flow                 } else if (data.event === 'ERROR') {                     const {                         error_message                     } = data.data;                     console.error("error ", error_message);                 }             }             document.getElementById("session-info-response").textContent = JSON.stringify(data, null, 2);         } catch {             console.log('Non JSON Responses', event.data);         }     });          const fbLoginCallback = (response) => {         if (response.authResponse) {             const code = response.authResponse.code;             // The returned code must be transmitted to your backend first and then             // perform a server-to-server call from there to our servers for an access token.             FB.api(                 "/debug_token?input_token=" + code,                 function (response) {                     if (response && !response.error) {                         /* handle the result */                         console.log(response);                         console.log('here12')                     }                      }             );         }         document.getElementById("sdk-response").textContent = JSON.stringify(response, null, 2);          }          const launchWhatsAppSignup = (e) => {         event.preventDefault();              // Launch Facebook login         FB.login(fbLoginCallback, {             config_id: '1707717083377865', // configuration ID goes here             response_type: 'code', // must be set to 'code' for System User access token             override_default_response_type: true, // when true, any response types passed in the "response_type" will take precedence over the default types             scope: "business_management, whatsapp_business_management, whatsapp_business_messaging",             extras: {                 setup: {},                 featureType: '',                 sessionInfoVersion: '2',             }         });     }     window.fbAsyncInit = function () {         FB.init({             appId: '521724357037484',             autoLogAppEvents: true,             xfbml: true,             version: 'v20.0'         });     };                               

I have the permissions public_profile, email, pages_read_engagement, instagram_basic, instagram_manage_insights, pages_show_list, read_insights, business_management. When I make a request to the API https://graph.facebook.com/v19.0/{your-user-id}/accounts?access_token={user-access-token} using a user ID and user access token, I sometimes get account data for some users, but for others, I receive empty data.

I encountered this issue before adding the business_management permission. After adding that permission, everything worked fine, but starting yesterday, users have been notifying me that they can't get account info.

I'm try to access Facebook API and when I try to choose get page access token in Graph API Explorer because user access token only gives permission to email. But it gives error :

    Error Invalid Scopes: manage_pages, pages_show_list. This message is only shown to developers. Users of your app will ignore these permissions if present. Please read the documentation for valid permissions at: https://developers.facebook.com/docs/facebook-login/permissions 

but in the doc it says

If your app is in development, you can grant your app any permission and your queries respect them for data owned by people with a role on your app. If your app is live, however, granting a permission that your app has not been approved for by the App Review process causes your query to fail whenever you submit it.

my app in development mode too.

This is the Error:

Anyone know a fix?

Emojis sent through the Facebook API are not displayed correctly on Facebook.

This functionality used to work, but now, instead of emojis, the symbols “?” are displayed. I tried using UNICODE, HTML code and shortcode.

The problem can be reproduced in the Graph API Explorer.

Link to the Graph API Explorer

For the test I used the following steps.

  1. I took a Facebook profile ID.

GET /v20.0/me?fields=id,name

  1. I created a video broadcast.
POST /v20.0/<USER_ID>/live_videos status="LIVE_NOW" title="Front 😝" description="Front 😝" 
  1. After I started the broadcasting the Facebook post become visible.

  2. After that, I made a request, using the broadcast ID, to receive the stream link.

The streaming link format as follows:

rtmps://live-api-s.facebook.com:443/rtmp/FB-1013749643592269-0-AbzJB6nb_Z183JwA,

To get the streaming link I made the following request:

GET /v20.0/<LIVE_VIDEO_ID>

  1. I started a broadcast in "OBS Studio" with that streaming link.

  2. I ended up checking the post on Facebook.

Facebook SDK for PHP (v5)

I'm using Graph API Explorer v20

Creating a video broadcast.

Getting the streaming url and broadcast title.

Result on Facebook.

Documentation for creating a live broadcast.

I want to post something in my FB feed wall (not any Page) using graph API. The Permissions:

pages_show_list instagram_content_publish pages_read_engagement pages_read_user_content pages_manage_posts pages_manage_engagement 

User or Page: User Token. Thus I generated the Access Token.

Next I am using the curl:

curl -X POST "https://graph.facebook.com/v20.0/me/feed" \      -H "Content-Type: application/json" \      -d '{            "message": "some msg",            "link": "some link to an image",            "published": "true",            "access_token": "the access token I got as mentioned above" 

And I am getting this error:

 }' {"error":{"message":"(#200) If posting to a group, requires app being installed in the group, and \\\n          either publish_to_groups permission with user token, or both pages_read_engagement \\\n          and pages_manage_posts permission with page token; If posting to a page, \\\n          requires both pages_read_engagement and pages_manage_posts as an admin with \\\n          sufficient administrative permission","type":"OAuthException","code":200,"fbtrace_id":"AT-wsNX19z1oFPFxq0tbLZF"}}%   

What I do not understand about the error message is that I am trying not to post in any group/page, but just my FB feed wall.

But later, I decided to create a Page, and try posting there. The code I used to get the Page is:

url -X GET "https://graph.facebook.com/v20.0/me/accounts?access_token=theaccesstoken >>> [{"access_token":"some access token, I am not sure what this is","category":"Property","category_list":[{"id":"198327773511962","name":"Property"}],"name":"MyTest","id":"394143863782471","tasks":["ADVERTISE","ANALYZE","CREATE_CONTENT","MESSAGING","MODERATE","MANAGE"]}],"paging":{"cursors":{"before":"QVFIUkVZASmx4RXhWemFZAX19pOGZALaTZAfMVJlTUtpaXZALMVlucnZAhVnc4WktZAV1hYUm1JTjE4NW5EOUdCYjRoTGRnLU1xSl9VZAi1qZAy1wbVJ6UWJ1cENHaXRR","after":"QVFIUkVZASmx4RXhWemFZAX19pOGZALaTZAfMVJlTUtpaXZALMVlucnZAhVnc4WktZAV1hYUm1JTjE4NW5EOUdCYjRoTGRnLU1xSl9VZAi1qZAy1wbVJ6UWJ1cENHaXRR"}}} 

I assume that 394143863782471 is the page_id as yes the name of my page is MyTest.

Then I used from here:

curl -X POST "https://graph.facebook.com/v20.0/394143863782471/photos" \      -F "source=@/path to my image" \      -F "caption=some caption" \      -F "access_token=the access token of the app >>> {"error":{"message":"(#200) The permission(s) publish_actions are not available. It has been deprecated. If you want to provide a way for your app users to share content to Facebook, we encourage you to use our Sharing products instead.","type":"OAuthException","code":200,"fbtrace_id":"AWHagdudbcBgpKNO6yPYM73"}}%    

I cannot understand what this error means. Can someone help?