Posts tagged with facebook-graph-api

I have a Facebook token that I'm trying to access Pages with but the API is returning an empty array. That seems like a simple permissions issue but when I debug the token in Facebook's Token Debugger it shows I have permissions to multiple pages.

Is there a way to get the pages to show up in the /me/accounts endpoint? Or is there an endpoint that can get me the granular scopes as listed on the Token Debugger?

I am using python sdk facebook_bussiness for acceissng meta apis. So when we create ad we have to choose the call to action depending on the type of media uploaded if media is an image then CTA would be differnet and diffirent for Videos. My questions is there any endpoint/function in the sdk which return me the CTAs depending on the media type, so that I don't have to hardcore values in code.

Following facebook's GraphAPI docs, i got a post request as seen below:

https://graph.facebook.com/v20.0/{pageid}/photos?access_token={here I insert a permanent PAGE token}&url={here i insert a url of a image that does exist} 

The response of this post request is:

 "error": {     "message": "(#200) The permission(s) publish_actions are not available. It has been deprecated. If you want to provide a way for your app users to share content to Facebook, we encourage you to use our Sharing products instead.",     "type": "OAuthException",     "code": 200,     "fbtrace_id": "Asd0O0G-dN02eCY9jLJjQGG"   } } 

Using the answers from others having the same error, I tried using permanent and short-term USER/PAGE access tokens. All resulted in the exact same error

I have and Facebook developer account created around 4 years before. The problem is when i try to fetch page videos, its not returning any result.

Note: i am using laravel-socialite package and the app is not verified yet.

When tried to debug i found out that the auth toke does not contain "pages_read_user_content" this permission.

On my laravel code i have added this permission but still when i am doing authentication its not showing this permission.

public function login(){     return Socialite::driver('facebook')         ->stateless()         ->setScopes(['pages_read_engagement', 'pages_show_list', 'pages_read_user_content'])         ->usingGraphVersion('v20.0')         ->redirect(); } 

Approach i tried :

To test this i created a new facebook developers account and did all the process and boom it worked. I am attaching the screenshot of permission detail with new developer account.

So the issue is its not working with my old account. Can anyone suggest how to fix this.

Thanks.

I want to get week to date list of country names with respective count of followers in that week or date.

Facebook is always giving data of life time.

The code I have used is as follows:

import datetime # Calculate timestamps for your custom date range start_date = '2024-06-01'  # Replace with your desired start date end_date = '2024-06-15'    # Replace with your desired end date # Convert dates to datetime objects start_datetime = datetime.datetime.strptime(start_date, '%Y-%m-%d') end_datetime = datetime.datetime.strptime(end_date, '%Y-%m-%d') # Calculate timestamps start_timestamp = int(start_datetime.timestamp()) end_timestamp = int(end_datetime.timestamp()) # Define the endpoint URL url = f'https://graph.facebook.com/v17.0/{page_id}/insights/page_fans_country/day' # Specify the access token and the period params = { 'access_token': access_token, 'since': start_timestamp, 'until': end_timestamp } # Make the request to the Graph API response = requests.get(url, params=params) # Check if the request was successful if response.status_code == 200:  insights_data = response.json()  # Print the retrieved insights data  print(json.dumps(insights_data, indent=4)) else:  print(f"Error: {response.status_code}")  print(response.json()) 

How to get this data.