Posts under category facebook-graph-api

I have two function. One is responsible for creating audience for the engaged page of Facebook and the other is for creating a custom audience for Instagram business account. I am using step functions to call my lambdas function. But whenever I try to create audience of Facebook and Instagram simultaneously, so I received an error of permission

No permission on event source: You do not have permission to create an audience on one or more event sources

But when I try to create a single audience for example just only for Facebook or just only for Instagram there is no error for the permissions but when I try to create audience simultaneously for the Facebook and for the Instagram business account I got this error

const createSocialAudience = async ({     name,     pageId,     adsAccountId,   } ) => {     if (!name || !adsAccountId || !pageId) {       throw new Error('Marketing API call missing required params');     }     const requestData = {       name,       description: 'Recent page visitors (from 360 days) visiting given page',       rule: {         inclusions: {           operator: 'or',           rules: [             {               event_sources: [                 {                   type: "page",                   id: pageId,                 },               ],               retention_seconds: 60* 60* 24 * 360,               filter: {                 operator: 'and',                 filters: [                   {                     field: 'event',                     operator: 'eq',                     value: 'page_engaged',                   },                 ],               },             },           ],         },       },       access_token: params.marketingApiToken,     };     const { data } = await httpClient.post(       `https://graph.facebook.com/v19.0/act_${adsAccountId}/customaudiences`,       JSON.stringify(requestData)     );     return data;   };   const createInstagramAudience = async ({     name,     igUserId,     adsAccountId,   })  => {     if (!name || !adsAccountId || !igUserId) {       throw new Error('Marketing API call missing required params');     }     const requestData = {       name,       description: 'Recent page visitors (from 360 days) visiting given page',       rule: {         inclusions: {           operator: 'or',           rules: [             {               event_sources: [                 {                   type: 'ig_business',                   id: igUserId,                 },               ],               retention_seconds: 60 *60 * 24 * 360,               filter: {                 operator: 'and',                 filters: [                   {                     field: 'event',                     operator: 'eq',                     value: 'ig_business_profile_engaged',                   },                 ],               },             },           ],         },       },       access_token: params.marketingApiToken,     };     const { data } = await httpClient.post(       `https://graph.facebook.com/v19.0/act_${adsAccountId}/customaudiences`,       JSON.stringify(requestData)     );     return data;   }; 

Expecting to create both of my audience at the same time for example I want two type of event_sources one for page of Facebook and one for ig_business

I am creating facebook video ads with google app script, for this first I have to upload video with this endpoint: "https://graph-video.facebook.com/v19.0/pageId/videos". complete code function is this:

function uploadVideoChunk(pageId, uploadSessionId, startOffset, videoChunk) {     //return uploadFileFetch(pageId, uploadSessionId, startOffset, videoChunk)     var url = "https://graph-video.facebook.com/v19.0/" + pageId + "/videos";     var payload = {       "upload_phase": "transfer",       "access_token": page_access_token,       "upload_session_id": uploadSessionId,       "start_offset": startOffset,       "video_file_chunk": videoChunk     };     var options = {       "method": "POST",       "payload": payload,       "muteHttpExceptions": true     };     var response = UrlFetchApp.fetch(url, options);     var responseData = JSON.parse(response.getContentText());     console.log('upload Video Chunk responseData = ',responseData)     var newStartOffset = responseData.start_offset;          return newStartOffset; } 

I am getting this error: Your video upload timed out before it could be completed. This is probably because of a slow network connection or because the video you're trying to upload is too large. Please try again

could you please help how can I solve this.

Thank you

I am following this: https://developers.facebook.com/docs/video-api/guides/publishing/#step-2--upload-chunks-individually

  1. I have created the app.
  2. I used the short-lived user access token to get a long-lived user access token.
  3. Then I tried to exchange the long-lived user access token for a long-lived page access token.
  4. This is the response I am getting:
    {      "error": {         "message": "(#15) This method must be called with an app access_token.",         "type": "OAuthException",         "code": 15,         "fbtrace_id": "AaKKgfwJzZsNDXADht1N7wy"      }     } 
  1. This is the endpoint for the API call to receive a long-lived page access token:
https://graph.facebook.com/v19.0/{app-id}/accounts?access_token={long-lived-user-access-token} 
  1. The endpoint for long-lived user access token:
https://graph.facebook.com/v19.0/oauth/access_token?grant_type=fb_exchange_token&client_id={app-id}&client_secret={app-secret}&fb_exchange_token={short-lived-user-access-token} 
  1. According to this documentation, I need to exchange a long-lived user access token in order to get a long-lived pages access token: Facebook Developer Documentation

I'm testing sending media headers through the WhatsApp API. But I keep getting the following error:

{     "error": {         "message": "(#132012) Parameter format does not match format in the created template",         "type": "OAuthException",         "code": 132012,         "error_data": {             "messaging_product": "whatsapp",             "details": "header: Format mismatch, expected VIDEO, received UNKNOWN"         },         "fbtrace_id": "AVPT6EiX3RemyP3uv4S36FZ"     } } 

I'm using a video URL to send the message and confirmed the video is publicly viewable. But I also got the same error when using the video link in the template. I know that there is a Resumable API for uploading the media, but that is not what I'm testing for here.

Any help would be appreciated.

For reference, this is the template:

{             "name": "vid_test",             "previous_category": "UTILITY",             "components": [                 {                     "type": "HEADER",                     "format": "VIDEO",                     "example": {                         "header_handle": [                             "https://scontent.whatsapp.net/v/t61.29466-34/380066992_950204086818012_8956032979900394560_n.mp4?ccb=1-7&_nc_sid=8b1bef&_nc_ohc=pmivIdgTvrAQ7kNvgEgxK28&_nc_oc=Adg2vVNVfN1TlUWzFmJxHpa830uVJRRCSKsooFiDp0E_AQ7gLbB-RIGSlx8UNvM0cXw&_nc_ht=scontent.whatsapp.net&edm=AH51TzQEAAAA&oh=01_Q5AaIFBxPaJzBmN9IaDMHWuIw-w8fQX3uHngw2A_qNyhKBVw&oe=666BB20F"                         ]                     }                 },                 {                     "type": "BODY",                     "text": "tesing {{1}} and use code {{2}} to get amazing discounts on testing videos.",                     "example": {                         "body_text": [                             [                                 "Message content",                                 "MSG25"                             ]                         ]                     }                 },                 {                     "type": "FOOTER",                     "text": "Use the buttons below to manage your marketing subscriptions"                 },                 {                     "type": "BUTTONS",                     "buttons": [                         {                             "type": "QUICK_REPLY",                             "text": "Unsubscribe from Promos"                         },                         {                             "type": "QUICK_REPLY",                             "text": "Unsubscribe from All"                         }                     ]                 }             ],             "language": "en",             "status": "APPROVED",             "category": "MARKETING",             "id": "950180443487043"         } 

And the POST message body:

{   "messaging_product": "whatsapp",   "recipient_type": "individual",   "to": "MY PHONE NUMBER",   "type": "template",   "template": {     "name": "vid_test",     "language": {       "code": "en"     }   },   "components": [     {       "type": "header",       "parameters": [         {           "type": "VIDEO",           "video": {             "Link": "https://static.vecteezy.com/system/resources/previews/006/996/488/mp4/timelapse-full-sunset-free-video.mp4"           }         }       ]     },     {       "Type": "Body",       "parameters": [         {           "type": "text",           "text": "Var 1"         },         {           "type": "text",           "text": "Var 2"         }       ]     }   ] } 

I'm using a rich text editor to create social media posts' text and I save it in DB as HTML to keep the format, I want to send these texts to Facebook Graph API formatted for example:

// DB <p>✨ <strong>Discover Elegance Redefined</strong>! Explore the brilliance of this meticulously crafted <em>platinum engagement ring</em>, featuring a stunning <strong>pavé diamond band</strong> that perfectly complements its breathtaking <strong>center stone</strong>. 💍 #ForeverBrilliant #EngagementRing #LuxuryJewelry #DiamondLove ✨</p> 

//FB ✨ Discover Elegance Redefined! Explore the brilliance of this meticulously crafted platinum engagement ring, featuring a stunning pavé diamond band that perfectly complements its breathtaking center stone. 💍 #ForeverBrilliant #EngagementRing #LuxuryJewelry #DiamondLove ✨

I tried to use HTMLPurifier Library but still not working