Posts under category Facebook Graph API

When creating a Consumer app with the Facebook Login product added (not Facebook Login for Business) you get a simple, single-step dialog to login. You just press "Continue as..." and it's done.

However, you are limited to only two scopes: public_profile and email. The only way I can get additional scopes is to create a Business app and add the Facebook Login for Business product. After doing this the login dialog is completely different. It's a much more complex, multi-step dialog that requires you to choose which businesses to opt-in and other things that need to be configured/confirmed.

It would seem that requesting permissions other than public_profile,email requires a Business app with Facebook Login for Business and the more complex login dialog, but there's a service we use called Flockler that lets you connect your Facebook/Instagram account and this is their Facebook dialog:

Their app uses the Consumer login dialog, but requires all these permissions: pages_read_user_content,pages_read_engagement,pages_manage_metadata,read_insights,business_management,instagram_basic,instagram_manage_comments,instagram_manage_insights

My question is, how can they have the simple Consumer login dialog while requiring all these additional permissions, when the only two permissions available in a Consumer app are public_profile and email?

Im trying to get all the comments of the posts, im using the after and before things of the cursor in Facebook graph, but it does not give me all comments.

const fetchAllPostComments = async (postId: string, after: string | null = null, limit: number = 25): Promise<any[]> => {     const pageQuery = after ? `&after=${after}&limit=${limit}` : `&limit=${limit}`;     const response = await fetch(`${GRAPH_API_URL}/${postId}/comments?access_token=${PAGE_ACCESS_TOKEN}${pageQuery}`);     const data = await response.json();     let allComments = data.data || [];     if (data.paging && data.paging.cursors && data.paging.cursors.after) {         const nextComments = await fetchAllPostComments(postId, data.paging.cursors.after, limit);         allComments = allComments.concat(nextComments);     }     console.log(allComments);     return allComments; }; 

I use facebook graph api in my app and I faced some issues I cannot crack for a while. Unfortunately their documentation is not always clear, so I would appreciate any tips on my questions. My app is build in Next.js, but I don't think language matters here.

1.Upload video trouble.

I follow this documentation. https://developers.facebook.com/docs/video-api/guides/publishing Publish video on the page takes three steps. 1.1 Start an upload session. I use here my business app Id and my test user account for user access token

 curl -i -X POST "https://graph.facebook.com/v20.0/<APP_ID>/uploads  ?file_name=<FILE_NAME>  &file_length=<FILE_LENGTH>  &file_type=<FILE_TYPE>  &access_token=<USER_ACCESS_TOKEN>" 

I get successfull return

{   "id": "upload:<UPLOAD_SESSION_ID>" } 

1.2. Start upload session. Same user token as in the first call and upload session Id which I received in the first response. Currently I test in Postman, so no issues yet converting video file, just file attached type video/mp4.

 curl -i -X POST "https://graph.facebook.com/v20.0/upload:<UPLOAD_SESSION_ID>"   --header "Authorization: OAuth <USER_ACCESS_TOKEN>"   --header "file_offset: 0"   --data-binary @<FILE_NAME> 

Success. Receive file handle response

{    "h": "2:c2FtcGxl..." } 

1.3. Publish video. And here is an error

 curl -X POST \   "https://graph-video.facebook.com/v20.0/<PAGE_ID>/videos" \   -F "access_token=<PAGE_ACCESS_TOKEN>" \   -F "title=<VIDEO_TITLE>" \   -F "description=<VIDEO_DESCRIPTION>" \    -F "fbuploader_video_file_chunk=<UPLOADED_FILE_HANDLE>" 

Page Id I use Page from my test user account, page token from this page. Handle - response from previous step. It end up in response:

{    "error": {       "message": "(#100) Using file handle created for another user",       "type": "OAuthException",       "code": 100,       "fbtrace_id": "AOF82skhP9OWC_yFlh_ka4q"    }  } 

Question? For whom did they create a handle?? Which another user? I use page credentials which belong to the user, whom user_token I used in the first steps. I follow all official documentation with headers, I insert user token in the header in the second step, as required, but I always end up with this error. Any ideas what potentially can go wrong?

2.Post Page insights for analytics.

I get analytics for page following this documentation https://developers.facebook.com/docs/graph-api/reference/v20.0/insights

For example call

  GET v20.0/{Page_Id}/insights?metric=page_post_engagements,page_daily_follows&period=week&since=01.09.2024&untill=30.09.2024 

There are three options for most of metrics - day, week and days_28. What is not clear for me, its's how to combine it with 'since' and 'untill'? I have an interactive page, where user can dynamically select 'period', 'since' and 'untill with datePicker, It always shows different data and I'm not sure what exactly I display.. for the call

 page_id/insights?metric=page_post_engagements&since=01.09.2024 

I will receive data for day, week, and day_28, per day since selected date till today. But data for the same day in each of there three sections will differ. What does this data represent? Example response:

 "name": "page_post_engagements",   "period": "day",   "values": [     {       "value": 0,       "end_time": "2024-09-02T07:00:00+0000"     },     {       "value": 0,       "end_time": "2024-09-03T07:00:00+0000"     },     {       "value": 0,       "end_time": "2024-09-04T07:00:00+0000"     },     {       "value": 0,       "end_time": "2024-09-05T07:00:00+0000"     },     {       "value": 9,       "end_time": "2024-09-06T07:00:00+0000"     },     {       "value": 4,       "end_time": "2024-09-07T07:00:00+0000"     }, }, {   "name": "page_post_engagements",   "period": "week",   "values": [     {       "value": 0,       "end_time": "2024-09-02T07:00:00+0000"     },     {       "value": 0,       "end_time": "2024-09-03T07:00:00+0000"     },     {       "value": 0,       "end_time": "2024-09-04T07:00:00+0000"     },     {       "value": 0,       "end_time": "2024-09-05T07:00:00+0000"     },     {       "value": 9,       "end_time": "2024-09-06T07:00:00+0000"     },     {       "value": 13,       "end_time": "2024-09-07T07:00:00+0000"     }, }, {   "name": "page_post_engagements",   "period": "days_28",   "values": [     {       "value": 5,       "end_time": "2024-09-02T07:00:00+0000"     },     {       "value": 5,       "end_time": "2024-09-03T07:00:00+0000"     },     {       "value": 5,       "end_time": "2024-09-04T07:00:00+0000"     },     {       "value": 5,       "end_time": "2024-09-05T07:00:00+0000"     },     {       "value": 14,       "end_time": "2024-09-06T07:00:00+0000"     },     {       "value": 18,       "end_time": "2024-09-07T07:00:00+0000"     }, 

Can someone explain me please? If I want, for example, display : "Your page activity this week increased/dropped for 15% compare to last week", how do I need to set my search params?

Thanks everyone for any ideas

I am creating a web app which uses Facebook graph apis to allow users connect their Facebook and Instagram account to my app so we could automate content posting on their behalf. I have successfully implementend for Facebook but the problem is now with Instagram. After I initiate the auth url I am taken to a page where I'm asked to enter my IG email and password, a popup opens and I enter those details but it doesn't get past there, it just goes back to telling me to "Get started" which is where I started from.

I have been strugling with this problem for days now and would greatly appreciate any help I could get with this.

Another guess I have: Though I doubt that is the case but could this be happening because I am yet to submit my app for review? If so, why did it work for Facebook?

What I have tried:

  1. I have added and double checked my redirect_uri both on my website and my Facebook developers App
  2. Checked if this issue persists across multiple browsers

What I expect: After entering my instagram username and password, I should be redirected to my redirect_uri with the access_token and other requested information so I can process them

I use the app for - FB login (for employees in the organization only) - Collect published post data of the authorized pages - Collect page insights & post insights data of the authorized pages - Collect comments of some posts
So I don't understand where I used the Business Asset User Profile Access permission. I tried to send a review several times but it didn't go through. I asked back what the API end point is that uses this permission. FB didn't have an answer. Is there anyone who can suggest a solution to this problem?