Server : LiteSpeed
System : Linux terra.hostitbro.com 5.14.0-611.54.3.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Thu May 7 16:31:24 EDT 2026 x86_64
User : outerorb ( 1091)
PHP Version : 8.1.34
Disable Function : mail
Directory :  /home2/outerorb/crm.outerorbittech.com/notify/

📁 Create New:
⬆️ Upload File:
Current Dir [ Writable ] Root [ Writable ]


OR Upload from URL:
URL: Save as:

📄 File: Firebase.php

Path: /home2/outerorb/crm.outerorbittech.com/notify/Firebase.php

Size: 2.48 KB

Permissions: 0664

<?php
 
// Firebase API Key
define('FIREBASE_API_KEY', 'AAAAquSO97E:APA91bHqx6gNziFXmrvMIeUuWtxow2evoQs9LNL9nuJHlwz1yImhbkIGE8jh3ElC7kAlq8OJrMUmCjybRwIvniGrJFzzO7H146ImQiHkANmCCwquWt-fYsmGSv8X7AA6fdSyY_cf76_r');
//AAAAnqxQ9Vk:APA91bFCafVS3xygcZy1uxOjG-WcfYONCqwu1X8yR_weK7GuJxY5JxrcTclOKriJP4y4wKCrStlcxhmCt9gfui_uJg39TSrWcnNaRysirjC7ZW83OpfjbDtTEgk1V1AZVSHZksoAylOT

/**
 * @author Ravi Tamada
 * @link URL Tutorial link
 */
class Firebase {
 
    // sending push message to single user by firebase reg id
    public function send($to, $message) {
        $fields = array(
            'to' => $to,
            'data' => $message,
        );
        return $this->sendPushNotification($fields);
    }
 
    // Sending message to a topic by topic name
    public function sendToTopic($to, $message) {
		$fields = array(
            'to' => '/topics/' . $to,
            'data' => $message,
			'priority' => 'high',
			'notification' => $message['data']['notification']
		);
        return $this->sendPushNotification($fields);
    }
 
    // sending push message to multiple users by firebase registration ids
    public function sendMultiple($registration_ids, $message) {
        $fields = array(
            'registration_ids' => $registration_ids,
            'data' => $message,
			'priority' => 'high',
			'notification' => $message['data']['notification']
        );
 
        return $this->sendPushNotification($fields);
    }
 
    // function makes curl request to firebase servers
    private function sendPushNotification($fields) {
 
        // Set POST variables
        $url = 'https://fcm.googleapis.com/fcm/send';
 
        $headers = array(
            'Authorization: key=' . FIREBASE_API_KEY,
            'Content-Type: application/json'
        );
        // Open connection
        $ch = curl_init();
 
        // Set the url, number of POST vars, POST data
        curl_setopt($ch, CURLOPT_URL, $url);
 
        curl_setopt($ch, CURLOPT_POST, true);
        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
 
        // Disabling SSL Certificate support temporarly
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
 
        curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));
 
        // Execute post
        $result = curl_exec($ch);
        if ($result === FALSE) {
            die('Curl failed: ' . curl_error($ch));
        }
 		// print_r($result);
        // Close connection
        curl_close($ch);
 
        return $result;
    }
}
?>

← Back to Directory Edit File 🔒 Chmod

WP File Manager