Posts under category facebook-graph-api

import requests import pandas as pd import json page_id = "61554487605477" post_id = "122107628540149586" access_token = 'EAAPaIduWx3MBOwj4GBHjpt6xjMRxncIvfCYNNqlWGHDaURhZC1AeDyb3MLjNpz8WbyzyuI84nIVffDxAxnKiyPZA0PvdX45fHQkq0oXz2YI9y41SF1tI2HYDBZAD15CftytfiC9QeBb0dlZCNoDGKvSzf6CAZBnZBBxfHusaFUIeRPtPonZCUV660y0VgNwQFGnVVibWMlJMtZB99G5l5OaiXN1JbD1ySHbZAQowtiMZD' # your access token, from https://developers.facebook.com/tools/explorer/ url = f'https://graph.facebook.com/v16.0/{page_id}_{post_id}/comments?access_token={access_token}' response = requests.request("GET", url) # save name, time, message in excel file data = json.loads(response.text) # create object with only name, time, message print(data) def get_comment_text(comment):     return '{} '.format(comment["message"].replace("\n", " ")) # Create a string containing all comments without newlines text_data = ''.join(map(get_comment_text, data.get('data', []))) print(text_data) # Write the comments to a text file without newlines with open(r'C:\Users\Sanath\Desktop\comments_downloader\kindle.txt', 'w', encoding='utf-8') as text_file:     text_file.write(text_data) # Display success message print('Comments  to kindle.txt') 

i am trying to fetch the comments from my test facebook page by providing post and page id and access token by facebook graph api ...this used to work a few months ago but now after a couple of months when i came back to run the code this is my error message

{'error': {'message': '(#200) Missing Permissions', 'type': 'OAuthException', 'code': 200, 'fbtrace_id': 'AFywRxOtJT1dOeJwznncM48'}} Comments  to kindle.txt 

i want to fetch the comments and stored in a text file called kindle . these are the permissions that i have provided in graph api: pages_manage_cta

pages_manage_instant_articles pages_show_list read_page_mailboxes pages_messaging pages_messaging_subscriptions page_events pages_read_engagement pages_manage_metadata pages_read_user_content pages_manage_ads pages_manage_posts pages_manage_engagement....

even after providing all necessary permission i am recieving a oauthexception i have made sure that post id and page id are accurate and the access token is newly generated one

i have been trying to publish videos on a facebook page's story, but i havent been successful, i have tried using their apis and integrating with restfb as well, As for restfb, i was able to post on a facebook page's timeline, but not on their story, i have included the code showing my implementation using the facebook api and rest fb, thanks for checking out, i appreciate any assistance

public void postVideo(String contentUrl) throws MalformedURLException, FileNotFoundException, FacebookOAuthException {         Users loggedInUser = userService.getCurrentUser();         Socials social = socialsService.getSocialByPlatform(SocialPlatform.FACEBOOK);         UserSocials userSocial= userSocialsService.findUserSocial(loggedInUser, social).orElseThrow(()-> new UserException("User social not found"));         FacebookClient defaultFacebookClient = new DefaultFacebookClient(userSocial.getAccessToken(), Version.LATEST);         File videoFile = new File("uploads/" + contentUrl);         if (!videoFile.exists()) {             throw new FileNotFoundException("Video file not found at specified path.");         }         FileInputStream fileInputStream = new FileInputStream(videoFile); //       Implementation using facebook api //        MultiValueMap<String, Object> requestBody = new LinkedMultiValueMap<>(); //        requestBody.add("file", new FileSystemResource("uploads/" + contentUrl)); //        HttpHeaders headers = new HttpHeaders(); //        headers.setContentType(MediaType.MULTIPART_FORM_DATA); //        FBVideoStoryStartResponse fbVideoStoryStartResponse = webClient.post() //                .uri("https://graph.facebook.com/v18.0/"+userSocial.getSocialUserId()+"/video_stories", uriBuilder -> uriBuilder //                        .queryParam("upload_phase", "start") //                        .build()) //                .retrieve() //                .bodyToMono(FBVideoStoryStartResponse.class) //                .block(); //        System.out.println(fbVideoStoryStartResponse); //        if(fbVideoStoryStartResponse != null){ //            FBVideoStoryUploadStatus fbVideoStoryUploadStatus = webClient.post() //                    .uri("https://rupload.facebook.com/video-upload/v18.0/" + fbVideoStoryStartResponse.getVideoId()) //                    .headers(httpHeaders -> httpHeaders.addAll(headers)) // Add the headers to the request //                    .bodyValue(requestBody) //                    .retrieve() //                    .bodyToMono(FBVideoStoryUploadStatus.class) //                    .block(); //            System.out.println(fbVideoStoryUploadStatus); //            assert fbVideoStoryUploadStatus != null; //            if(fbVideoStoryUploadStatus.isSuccess()){ //                FBVideoStoryFinishResponse fbVideoStoryFinishResponse = webClient.post() //                        .uri("https://graph.facebook.com/v18.0/"+userSocial.getSocialUserId()+"/video_stories", uriBuilder -> uriBuilder //                                .queryParam("video_id", fbVideoStoryStartResponse.getVideoId()) //                                .queryParam("upload_phase", "finish") //                                .build()) //                        .retrieve() //                        .bodyToMono(FBVideoStoryFinishResponse.class) //                        .block(); //                System.out.println(fbVideoStoryFinishResponse); //            } //        } //      Implementation using restfb         FBVideoStoryStartResponse fbVideoStoryStartResponse1 = defaultFacebookClient.publish(userSocial.getSocialUserId() + "/video_stories", FBVideoStoryStartResponse.class,                 Parameter.with("upload_phase", "start"));         String videoUploadID = fbVideoStoryStartResponse1.getVideoId();         System.out.println(videoUploadID);         GraphResponse graphResponse = defaultFacebookClient.publish(videoUploadID, GraphResponse.class, BinaryAttachment.with(videoFile.getName(), fileInputStream));         GraphResponse graphResponse1 = defaultFacebookClient.publish(userSocial.getSocialUserId() + "/video_stories", GraphResponse.class,                 Parameter.with("video_id", videoUploadID),                  Parameter.with("upload_phase", "finish"),                  Parameter.with("video_state", "PUBLISHED"),                 Parameter.with("description", "A short description text"));             try {                 fileInputStream.close();             } catch (IOException e) {                 throw new RuntimeException(e);             } } 

So using restfb, i get the error "There is a problem uploading your video, Please try again with another file" and i have tried with multiple files below a minute but still the same result.

I'm getting an error while posting a review on Facebook page using a "POST" method.

{ "error": { "message": "Unsupported post request. Object with ID '311823882006106' does not exist, cannot be loaded due to missing permissions, or does not support this operation. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api", "type": "GraphMethodException", "code": 100, "error_subcode": 33, "fbtrace_id": "Ar6_ieLkr0wegRXZ4uQtkoG" } }

But it was working good when I'm getting a review from Facebook page by using "GET" method

I just want to Post a reviews

the problem i have is that sync phone numbers through api cannot be done except if we hashed those phone numbers, when we hash those phone numbers FB will not be able to recognize and match the users and in the estimated audience size we will have below 1000 always and size will be always ---, i tried to change the format of the phone numbers and make them without + sign but it gave the same result unfortunately. i thought that maybe the phone numbers we are uploading has no FB accounts and because of that FB is not able to recognize them but when i uploaded them manually without hashing to FB audience list using FB panel there was matching and i got numbers in the estimated audience size when i tried to hash those same phone numbers and uploaded them manually but hashed to an audience list in FB panel i got the same issue (no recognition) i am hashing using the same method we are using for email (with email there is no issues and everything works as expected) i am using SHA256 for hashing as FB suggested in their documentation. and i am sending phone numbers with country code as FB suggests in their documentation so basically i am doing everything as they listed in their documentation but we are getting no fulfilling or satisfying results with matching. (PS: i am sending all the users and FB is not giving any errors while uploading those users.).

i tried to change the format of the uploaded phone numbers (i uploaded with and without + sign), i am using php laravel in my main project but i tried to hash and upload through golang but i got the same result. also i am normalizing the phone numbers as they listed in the documentation i am sending only numbers without any symbols and leading zeros.

i expect to have audience size when phone numbers uploaded similar to what it happen when emails are uploaded to an audience list.

audience size after upload to audience list manually

audience size after upload to audience list through api

I'm working with the Facebook Graph API to retrieve video insights, and I've encountered a situation where specifying the since and until parameters doesn't seem to affect the results when the period is set to "lifetime." Here's an example of the API request I'm using:

/[VIDEO_ID]/video_insights?metric=total_video_views&since=2023-01-01&until=2023-03-01&period=lifetime

Even when I include the since and until parameters to specify a time range within the lifetime period, I'm getting the same result as when I don't include these parameters. Additionally, I need to retrieve data for total_video_view_time_by_country_id and total_video_view_time_by_age_bucket_and_gender within the given period.

Has anyone else experienced a similar issue? Is there a specific reason why specifying the time range within the lifetime period wouldn't affect the results? Any insights or suggestions would be greatly appreciated!

Thanks in advance for your help! 🙏