import requests

# Replace with your actual access token
ACCESS_TOKEN = 'EAALt2fi3j08BO9J5SWNsiQhWZANuJK5XorEMjqanGtRJRk21ODv14mAYSI9nwc5cluShzGn1az4ZBqEzVkfZB32SxlEEPVcO1Vue3LYk6cJoHgt722Orh3pfHOaLbpzVzAOBdpLQE8AHy8hj7TK9ZBD3pZAaEGEJ2NyF8r8ZCZBcNPRBY5WYh2bJmJd0vIZC7gJftaqZB0ZBnmWLIZBmWVpPVbZAZBnHYbTSaZBxdIuovlltF2x2EjDJu6mvtj9EhAkcjovwdTFZC1yZCAZDZD'

# Instagram username to check
TARGET_USERNAME = 'singh.aman__23'

# List of Instagram post IDs
POST_IDS = [
    'C_KlYBqOeRt',
    'C_U9m5HvK3f',
    'C_VR68ZpxUT',
    'C_VUvUqtJLr',
    'C_SrZUZJ9SS'
]

# Assume you obtained the User ID manually or through some method
TARGET_USER_ID = '122100619622526049'

def get_likes_for_post(post_id, access_token):
    """Fetch the list of user IDs who liked a specific post."""
    url = f'https://graph.instagram.com/{post_id}/likes'
    params = {
        'access_token': access_token
    }
    response = requests.get(url, params=params)
    
    if response.status_code == 200:
        return response.json().get('data', [])
    else:
        print(f"Error fetching likes for post {post_id}: {response.status_code} - {response.text}")
        return []
import time
def check_if_user_liked_posts(user_id, post_ids, access_token):
    """Check if a specific user has liked any of the given posts."""
    for post_id in post_ids:
        liked_users = get_likes_for_post(post_id, access_token)
        user_ids = [user['id'] for user in liked_users]
        if user_id in user_ids:
            print(f"User {user_id} has liked post {post_id}.")
        else:
            print(f"User {user_id} has not liked post {post_id}.")
        time.sleep(2)

def main():
    try:
        check_if_user_liked_posts(TARGET_USER_ID, POST_IDS, ACCESS_TOKEN)
    except Exception as e:
        print(f"An error occurred: {e}")

if __name__ == "__main__":
    main()
