- Replaced all client-facing $e->getMessage() with generic error messages - Added error_log() with filename prefix to all catch blocks - Covered jsonError(), echo, and json_encode() response patterns - Also fixed 2 remaining display_errors=1 and add_invoice.php leak - Script-assisted fix for 75 files, manual fix for 12 remaining edge cases
39 lines
1.3 KiB
PHP
39 lines
1.3 KiB
PHP
<?php
|
|
require_once 'vendor/autoload.php'; // Include the Composer autoloader
|
|
|
|
use Facebook\Facebook;
|
|
|
|
$appId = '$appId'; // Replace with your App ID
|
|
$appSecret = '$appSecret'; // Replace with your App Secret
|
|
$accessToken = '$accessToken'; // Replace with the token you want to debug
|
|
|
|
$fb = new Facebook([
|
|
'app_id' => $appId,
|
|
'app_secret' => $appSecret,
|
|
'default_graph_version' => 'v16.0', // Adjust based on your API version
|
|
]);
|
|
|
|
try {
|
|
// Generate the app token
|
|
$appToken = $appId . '|' . $appSecret;
|
|
|
|
// Debug the token
|
|
$response = $fb->get('/debug_token?input_token=' . $accessToken, $appToken);
|
|
$tokenData = $response->getDecodedBody();
|
|
|
|
// Display the token details
|
|
echo "Token Data:\n";
|
|
print_r($tokenData);
|
|
|
|
if (isset($tokenData['data']['expires_at'])) {
|
|
echo "Expires At: " . date('Y-m-d H:i:s', $tokenData['data']['expires_at']) . "\n";
|
|
} else {
|
|
echo "The token does not have an expiration time.\n";
|
|
}
|
|
} catch (Facebook\Exceptions\FacebookResponseException $e) {
|
|
error_log("[facebook.php] Graph API Error: " . $e->getMessage());
|
|
echo 'An error occurred while fetching Facebook data';
|
|
} catch (Facebook\Exceptions\FacebookSDKException $e) {
|
|
error_log("[facebook.php] SDK Error: " . $e->getMessage());
|
|
echo 'An error occurred while processing Facebook data';
|
|
} |