PHP Examples
PHP examples for using the PageSight API with cURL.
Basic Request
Simple PHP example using cURL to make an API request.
Loading code...
With Error Handling
Proper error handling and response validation.
Loading code...
Custom Cache Duration (Pro Only)
Set cache duration to 30 minutes. Minimum is 5 minutes for Pro users.
Loading code...
Cache Revalidation (Pro Only)
Force a fresh scrape by bypassing the cache.
Loading code...
Reusable Client Class
A complete PHP class for interacting with the PageSight API.
Loading code...
Tips & Best Practices
✅ Do
• Use http_build_query() for URL parameters
• Always check HTTP status code
• Handle cURL errors properly
• Use environment variables for API keys
• Validate JSON response before using
❌ Don't
• Don't hardcode API keys
• Don't ignore cURL errors
• Don't skip HTTP status checks
• Don't use eval() with responses
• Don't forget to close cURL handles
PageSight