Posts tagged with facebook-javascript-sdk

I am currently working with the Meta Business Manager and the Facebook Graph API. In the Meta Business Manager UI, under Business Info, I can see a field labeled Ad account creation limit, which shows the maximum number of ad accounts that can be created for a particular business.

However, I am unable to find any relevant endpoint or field in the Facebook Graph API documentation that would allow me to fetch this information programmatically. I have searched through the available endpoints for businesses and ad accounts but haven’t found anything that matches.

Does anyone know if it's possible to retrieve the Ad account creation limit via the Facebook Graph API? If so, could you point me to the correct endpoint or provide an example of how to fetch this data?

My app was already live in facebook. I had then changed it back to "In development" , to integrate instagram. Although i did spend some time, i did not request for any new permission. I reverted any changes i had done to my developer account. The only change which i cannot revert is to remove Instagram from "Products" in my app.

My privacy policy url was always : https://hype.workflowlabsfusion.com/privacypolicy/index.html

It is accessible. Now when i try to change it to In development mode, facebook keeps giving the error

You must provide a valid Privacy Policy URL in order take your app Live. Go to Basic Settings and make sure it is valid. 

But my url is very much accessible, there is no change in content of the privacy policy. What is possibly going wrong ? I have been trying to resolve this from the past 2 days. Any help would be appreciated. Thanks.

Can not upload video file node.js to facebook graph api version v21,0 and error is video file not supported

I am Creating a ecommerce what will be able to post facebook the video events of the website .

and I am using facebook graph api version v21.0

for generating session id , I use

//FACEBOOK_GRAPH_API=https://graph.facebook.com //FACEBOOK_GRAPH_VERSION=v21.0 async function initInializeVideoUploadSession({file_name,file_length,file_type,access_token}) {     let url =makeUrlWithParams(`${FACEBOOK_GRAPH_API}/${FACEBOOK_GRAPH_VERSION}/${FACEBOOK_APP_ID}/uploads`,{         file_name,         file_length,         file_type,         access_token     });     log({url})     let res=await fetch(url, {         method :'POST'     });     res=await res.json();     if (!res.id) {         console.log(res);         throw 'Can not facebook token'     }     return res.id } 

for generating the file handle

 //FACEBOOK_GRAPH_API=https://graph.facebook.com //FACEBOOK_GRAPH_VERSION=v21.0 async function uploadAVideoFile(options) {     let prom= new Promise( async(resolve, reject) => {         let {             session,             access_token,             videoPath,             filename         }=options         let url =makeUrlWithParams(`${FACEBOOK_GRAPH_API}/${FACEBOOK_GRAPH_VERSION}/${session}`,{})         log({url})         request(url , {             method :'POST',              headers :{                 'Authorization':'OAuth '+access_token,                 'file_offset' :'0',                 'accapt':"video/mp4",                 'cache-control': 'no-cache',                 'content-type' : 'video/mp4',                 'content-disposition': 'attachment; filename=' + filename,                 'content-length':fs.statSync(videoPath).size.toString()             },             body :fs.readFileSync(videoPath,'binary'),             encoding :null         },responseCallBack)         function responseCallBack(error , response, data) {             data=JSON.parse(data);             log(data)             if (data.h) return resolve(data.h)             if (!data.h) {                 throw new Error('File Handler is not define')             }         }     })     let h=await prom.then(h => h)     return h    } 

By facebook api, I can generate session id ,file handle ,

but when I am using this file handle to post a video on facebook page i am getting error ,video format not supported,please see the upload video code

 async function videoFacebookApi(req,res) {     let {title,description,filename}=req.body;       try {         if (typeof title        !==  'string' ) throw 'title is null'         if (typeof description  !==  'string' ) throw 'description is null'         if (typeof filename     !==  'string' ) throw 'filename is null'         let access_token = await settingsAsString('fb_access_token');         let tokenDate    = await settingsAsString('fb_access_token_enroll_date');         if ( !access_token || !tokenDate) {             throw new Error('!FV_PAGE_ACCESS_TOKEN || !tokenDate')         }         updateFacebookApiAccessToken(tokenDate);         let videoPath=resolve(dirname(fileURLToPath(import.meta.url)), '../../../public/video/Beauty.mp4');                          log('// file upload session started')         let session=await initInializeVideoUploadSession({             file_name:filename,             file_length:fs.statSync(videoPath).size,             file_type:"video/mp4",             access_token         });         log('// file uploading started')         let file_handle= await uploadAVideoFile({             session,             access_token,             videoPath,             filename,             });         log('// video post started')         await request.post(makeUrlWithParams('https://graph-video.facebook.com'+'/'+FACEBOOK_GRAPH_VERSION+'/'+FB_PAGE_ID+'/videos',{}),             {             headers :{                 "Content-Type": "multipart/form-data",                 "accept": "*/*"             },             formData :{                 title,                 description,                 access_token,                 fbuploader_video_file_chunk:file_handle             }         }, uploadToFacebook );         async function uploadToFacebook(error, response, body) {             try {                     if (error) {                     console.error(error)                     return res.sendStatus(500)                 }                 if (body) {                     body=await JSON.parse(body)                     if (body.id) {                         console.log({body});                         console.log('//video upload completed');                                                  return res.sendStatus(201)                     }                     if (body.error) {                         console.error({...body.error});                         return res.sendStatus(400)                     }                     console.log({body});                     return res.sendStatus(200)                 }                 return res.sendStatus(200)             } catch (error) {                 console.log({error});                 return res.sendStatus(500)             }           }     } catch (error) {         log({error})         return res.sendStatus(500)     } } 

Please see the error carefully

{   message: "The video file you selected is in a format that we don't support.",   type: 'OAuthException',   code: 352,   error_subcode: 1363024,   is_transient: false,   error_user_title: 'Unsupported Video Format',   error_user_msg: "The video you're trying to upload is in a format that isn't supported. Please try again with a video in a supported format.",    fbtrace_id: 'ASMNMrVVh4jeY06_nDP_y9d' } 

then docomentation I am following for this functionality is facebook graph api docomentation

i want to give partner access of business assets to someone via Facebook api, but i have no idea how it can be done.

I tried to use page-id/assigned_users API to assign a page to the user but that also didn't worked, sometimes i got the error, that app-scoped id is invalid and other time i got error: "there is not business linked with this id".

I did some research over chatgpt, and what i got to know is, firstly i need to add the user to business manager and only then i can use above api. But i am not sure if the chatgpt answer is reliable or not.

I have read facebook documentation, but its very confusing !!!

I am new to facebook graph api, so any small help will be really appreciated.