I am stuck in this problem.In the below I gave my whole code.Here all the information is correct.But I still get this error
import requests
from urllib.parse import quote
access_token = 'EAAQIcI2JNTIBO1T9vAYZArxG3ZAHq2f8JFYtcZAmScgY7sJkAd9GSh1ZCUw2qpanidLRFNPoawrqZAGrC4YmDBQGsAnorNo4sC1lPcDQycrNdSStD9QIOG6nVTqzxU037jbOUaxO2Ac7pTvkq7TKfZCOGOhWyuY1jdTToOReKRftw4SH6ZCLvqIk3HiyZAfWfJVWKCJLZAgZDZD'
post_url = "(I gave a valid url)"
post_id = post_url.split('=')[-1]
encoded_post_id = quote(post_id, safe='')
graph_api_url = f'https://graph.facebook.com/v12.0/{encoded_post_id}?fields=likes.summary(true),shares,comments.summary(true)&access_token={access_token}'
response = requests.get(graph_api_url)
if response.status_code == 200:
data = response.json()
likes_count = data['likes']['summary']['total_count']
shares_count = data.get('shares', {}).get('count', 0)
comments_count = data['comments']['summary']['total_count']
print(f'Likes: {likes_count}')
print(f'Shares: {shares_count}')
print(f'Comments: {comments_count}')
else:
print("Error: Unable to access the Facebook post.")
For this code the output is 'Error: Unable to access the Facebook post.' I want to count facebook posts reaction,share,comment.Can anyone please help me...?
I am trying to count Facebook posts like,share,comment counting.But it gives an error for my given code.The error is "Error: Unable to access the Facebook post." How can I come out from this problem?