Posts tagged with facebook-graph-api

I'm trying to get some facebook user's permissions but not all of them are listed to the user to grant/decline.

Using the FBLoginButton and setting the permissions to:

- email - pages_show_list - instagram_basic - pages_read_engagement - business_management - instagram_manage_insights 

The user is presented only with public_profile (mandatory) and email, the rest are not shown to be granted/declined.

Any subsequent request doesn't show them either.

I also set button.authType = .rerequest

To note that when I created a new facebook account for testing and this worked just fine. Could it be a particular setting on some accounts to not ask these permissions. The account(s) with issues are personal accounts (mine / colleagues)

What am I missing here?

I am trying to retrieve the from field for comments on a post using the Facebook Graph API. The from field is showing correctly for page authors but not for regular users who comment on the post.

I have ensured that I have the required permissions, including:

email pages_show_list pages_read_engagement pages_read_user_content pages_manage_posts

The API request I am making is as follows:

**GET /{page_post_id}/comments** 

As per the Facebook Graph API documentation, this should return the from field for all comments. However, the from field is missing for users and is only available for page authors. i am also using user access and page access token as docs suggest but still the issue persist.

  1. Verified that I have all the required permissions.
  2. Checked the API request to ensure it was correctly formatted according to the documentation.
  3. Tried testing the request with different page posts and still encountered the same issue.
  4. Use Facebook graph API Explorer to test different permissions and endpoints. but there is also from field missing.

I have been researching several Stack Overflow articles but i did not point any potential solution, and it seems that many people are experiencing the same issue in the Facebook community. It would be very helpful if someone could provide me with the latest information. I need to know whether this is an issue with V20 or if I am missing something.

I expected the from field to return the information for both users and page authors, but it's only appearing for page authors.

I'm encountering an issue with the Facebook Graph API where the responses do not respect the specified date ranges in my queries. Here are the details of my requests and the responses I receive:

Query using time_range:

/campaigns?level=campaign&fields=account_id,effective_status,id,name,insights{reach,dda_results,frequency,cost_per_conversion,spend,impressions,cpm,clicks,cost_per_unique_click,purchase_roas,actions,action_values},lifetime_budget,start_time&limit=1&time_increment=1&time_range={'since':'2024-09-07','until':'2024-09-08'} 

Response:

"insights": {     "reach": "372827",     "date_start": "2024-08-12",     "date_stop": "2024-09-10" } 

Query using date_preset=yesterday:

/campaigns?date_preset=yesterday&level=campaign&fields=account_id,effective_status,id,name,insights{reach,dda_results,frequency,cost_per_conversion,spend,impressions,cpm,clicks,cost_per_unique_click,purchase_roas,actions,action_values},lifetime_budget,start_time&limit=1&time_increment=1 

Response:

"insights": {     "reach": "372827",     "date_start": "2024-08-12",     "date_stop": "2024-09-10" } 

Despite specifying narrow date ranges, the API returns data spanning almost a month. Has anyone else faced this issue, or can provide insights on how to enforce the specified date range in the query?

  • I'm using Laravel Socialite to handle Facebook authentication in my Laravel application, and I’m working in a test environment only. I have successfully integrated Socialite to allow users to log in with their Facebook accounts. Now, I need to fetch a list of the user's Facebook friends after they authenticate.

  • I've reviewed the Laravel Socialite documentation and the Facebook Graph API documentation, but I’m unsure how to proceed with obtaining the list of friends.

  • Facebook Permissions: I’ve made sure to request the user_friends permission during the login process.

  • API Calls: I’ve attempted to use the Graph API directly to fetch friends but haven't been able to integrate it smoothly with Socialite.

Here’s a snippet of the code I’m using to authenticate users:

public function redirectToProviderFacebook(){        return Socialite::driver('facebook')->scopes(['user_friends'])->redirect();     } public function handleProviderCallbackFacebook(Request $request){         try {             $user = Socialite::driver('facebook')->stateless()->user();             $accessToken = $user->token;             // Get friends             $response = Http::withToken($accessToken)                 ->get('https://graph.facebook.com/me/friends');             $friends = $response->json();             dd($friends);             $data = User::where`your text`('email', $user->email)->first();             if (is_null($data)) {                 $users['name'] = $user->name;                 $users['email'] = $user->email;                 $users['password'] = Hash::make('password');                 $data = User::create($users);             }             Auth::login($data);             return redirect('dashboard');         } catch (\Exception $e) {             // Log the error or return a meaningful message             Log::error('Facebook OAuth error: ' . $e->getMessage());             return redirect()->route('login')->with('error', 'Authentication failed.');         }     } 
  • How do I use Laravel Socialite to fetch a user’s list of friends from Facebook in a test environment?

  • Are there any specific settings or configurations needed in the Facebook Developer Console for accessing friends data in a test environment?

  • Can you provide an example of how to make a request to the Facebook Graph API to get friends data after authentication?

Any guidance or examples would be greatly appreciated!

I’m facing an issue where the Facebook Graph API is not returning lead data for a specific ad, even though the leads are visible in the Ads Manager.

Here’s what I’ve done: I’m using the following endpoint to retrieve the leads: GET /{ad_id}/leads?fields=id,created_time,field_data&limit=1000

The leads for other ads are returned correctly, but for one particular ad ("ad1 - Copy"), no leads are returned, even though I can clearly see them in the Facebook Ads Manager (65 leads in total). I’ve made sure that my access token has the required permissions: leads_retrieval ads_read ads_management pages_manage_ads I’ve also tried adding parameters like date_preset=maximum, but this doesn't help with retrieving the missing leads. I've checked Stack Overflow and the Facebook Developer forums, but I haven't found a solution specific to this issue. Has anyone encountered a similar issue, and is there a known fix or workaround for this discrepancy between the Ads Manager and the API? Any help or guidance would be greatly appreciated!

Environment: API version: v20.0 Access token permissions: leads_retrieval, ads_read, ads_management What I’ve Tried: Refreshing the token and regenerating it with proper permissions. Adding various query parameters (like limit and date_preset). Expected Behavior: The API should return all leads for "ad1 - Copy" just like it does for other ads.