Overview
The Facebook Client integration retrieves public page metadata using the Facebook Graph API v19.0. It does not use HTML scraping or login flows, and operates entirely through official API endpoints.Authentication
The client requires Facebook API credentials configured via environment variables:FACEBOOK_APP_ID- Facebook App IDFACEBOOK_APP_SECRET- Facebook App SecretFACEBOOK_ACCESS_TOKEN- (Optional) Access token. If not provided, will auto-generate using{APP_ID}|{APP_SECRET}format
Core Function
get_facebook_page_data()
Retrieves public Facebook Page metadata for a given URL.
Facebook page URL. Supports formats:
https://facebook.com/SomeBusinesshttps://www.facebook.com/SomeBusiness/
Returns
Always returns
"facebook"Unique Facebook Page ID from Graph API
Business or page name
Page description. Falls back from
about field to description fieldPage category (e.g., “Local Business”, “Restaurant”)
Total follower count (from
fan_count field)Associated website URL if provided on the page
Original URL that was analyzed
Synthesized text field for AI Evaluator compatibility. Combines all metadata into formatted string:
Present only when an error occurs. Contains error message
Error Handling
The function returns structured error responses instead of raising exceptions: Missing CredentialsAll errors are logged to
logs/extraction.log with ERROR level severity.Implementation Details
Graph API Request
The function queries these specific fields from the Graph API:URL Pattern Matching
Page identifier extraction uses regex:Timeout Configuration
Requests have a 10-second timeout:Integration with Lead Engine
The function integrates with the main extraction system by:- Accepting URLs from the Lead Engine’s URL router
- Returning normalized data structure compatible with AI Evaluator
- Providing
textfield for LLM analysis - Maintaining consistent error format across all extractors
Example Usage
Source Reference
Implementation:~/workspace/source/facebook_client.py:20