Posts tagged with facebook-graph-api

While Integrating the Facebook login for business I am facing "It looks like this app isen't available". I have followed all the steps mention in the META documentation. please click here to refer the images which I have followed.

<!DOCTYPE html> <html> <head>     <title>Facebook Login JavaScript Example</title>     <meta charset="UTF-8">     <script type="text/javascript" src="<c:url value='/facebooksdk/js/fbsdk.js'/>"></script>     <script>         window.fbAsyncInit = function() {           FB.init({             appId      : APPID,             cookie     : true,             xfbml      : true,             version    : APIVERSION,             response_type: "code"           });           checkLoginState();         };         (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'));       </script> </head> <body>       <fb:login-button onlogin="checkLoginState();"> </fb:login-button>     <div id="status">     </div> </body> </html> const APPID = "1450727115804587"; const APIVERSION = "v19.0"; const CONFIGID = "422168783777066"; 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.         document.getElementById('status').innerHTML = 'Please log '             + 'into this webpage.';     } } function checkLoginState() { // Called when a person is finished with the Login Button.     FB.getLoginStatus(function (response) { // See the onlogin handler         statusChangeCallback(response);     }); } function testAPI() {     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 + '!';     }); } 

Step 1 : Create a new app Note : I have selected Other option

Select an App Type -> I have selected an second option Business App Type

Provide App Name & Business Profile and click on Create App

(3.1) Business App details - Business app is verified

App Details : - Display Name - EduCRM - App Domain : educloud.app - Privacy policy & Terms of service Url : https://zdp2.educloud.app/lms/tandc - Category : Education - Image Update : Yes

Add Product “facebook login for business”

Click Setup button of Facebook Login for Business

Facebook Login for business get Advance permission Permission requested pages_show_list ads_management
leads_retrieval pages_read_engagement
pages_manage_metadata
pages_read_user_content pages_manage_ads
pages_manage_engagement public_profile

Configuration Quick Start steps: Select Web option : to get SDK code Make the App live :

I've read the docs and try to make a function to upload image on facebook and get its api but it seems not work at all. (the access token have permisson to do that request so ye)

def upload_image(token, gid, image_path):         res = requests.post(f"https://graph.facebook.com/{gid}/photos", params={"access_token": token}, files={"source": open(image_path, "rb")})         print(res.text)         return res.json().get("id") 

The weird part is I kept getting the error #324 (Requires upload file).

After uploading the photos I tried to create a ‘multiple-photos’ post with a Call To Action button attached to it, the issue is that the post is being created successfully when I don’t include the CTA but when I add the CTA button (2nd code block) the post is created without the photos, here below are the payloads I used on [POST] /{page_id}/feed.

//This will create the Post with Album as a type successfully {   "access_token": "<access_token>",   "published": 1,   "message": "An awesome Fb Post",   "attached_media": [     { "media_fbid": "<uploaded_photo_id>" },     { "media_fbid": "<uploaded_photo_id>" }   ] } 
//The Post will be created with the Call To Action Button but without photos {   "access_token": "<access_token>",   "published": 1,   "message": "An awesome Fb Post",   "attached_media": [     { "media_fbid": "<uploaded_photo_id>" },     { "media_fbid": "<uploaded_photo_id>" }   ],   "call_to_action": {     "type": "MESSAGE_PAGE",     "value": {       "app_destination": "MESSENGER",       "link": "https://fb.com/messenger_doc/"     }   } } 

Any Idea why the Post is not being created with both the images and the CTA button?

Thanks & I appreciate any feedback

I wish to use the created post in an AdCreative later on.

i wish to find a solution to this issue i have been facing for a long while, trying to publish a reel on instagram. It keeps returning this error: Media upload has failed with error code 2207026 which means its not in the required format, i have tried with countless videos, uploaded them to my google drive and input the link to the video but still the same error, i came across this: Facebook Graph API - Getting error 2207026 when trying to upload video

And also implemented the last suggesstion in my code as shown below:

public String uploadFile(MultipartFile file) {         String extension = StringUtils.getFilenameExtension(file.getOriginalFilename());         var key = UUID.randomUUID() + "." + extension;         String directory = this.fileStorageLocation;         Path newPath = Paths.get(directory).toAbsolutePath().normalize();         try {             Files.createDirectories(newPath);             Path inputFilePath = newPath.resolve(StringUtils.cleanPath(key));             Path outputFilePath = newPath.resolve("output.mp4");             Files.copy(file.getInputStream(), inputFilePath, StandardCopyOption.REPLACE_EXISTING);             executeFFmpegCommand(inputFilePath.toString(), outputFilePath.toString());         } catch (IOException ex) {             Logger.getLogger(FileService.class.getName()).log(Level.SEVERE, null, ex);         }         return key;     }     private void executeFFmpegCommand(String inputFilePath, String outputFilePath) throws IOException {         String ffmpegPath = "C:\\ffmpeg\\bin\\ffmpeg.exe";         String[] ffmpegCommand = {                 ffmpegPath,                 "-i", inputFilePath,                 "-c:v", "libx264",                 "-aspect", "16:9",                 "-crf", "18",                 "-vf", "scale=iw*min(1280/iw\\,720/ih):ih*min(1280/iw\\,720/ih),pad=1280:720:(1280-iw)/2:(720-ih)/2",                 "-fpsmax", "60",                 "-preset", "ultrafast",                 "-c:a", "aac",                 "-b:a", "128k",                 "-ac", "1",                 "-pix_fmt", "yuv420p",                 "-movflags", "+faststart",                 "-t", "59",                 "-y", outputFilePath         };         ProcessBuilder processBuilder = new ProcessBuilder(ffmpegCommand);         processBuilder.inheritIO();         Process process = processBuilder.start();         try {             process.waitFor();             System.out.println("FFmpeg command executed successfully.");         } catch (InterruptedException e) {             throw new IOException("Error executing FFmpeg command: " + e.getMessage(), e);         }     } 

And uploaded the video to my drive and put in the link again, but still the same error, i dont know could be the issue, could someone provide a suggestion or a link to a video that has been tested with, because i dont see what am doing wrong, thanks.