Sending Push notification through pushwoosh from php

PHP Pushwoosh notification using Pushwoosh API

Pushwoosh is real time cross-platfrom service to send push notification on android and IOS mobile application.

To send and push notification fro PHP pannel we need push auth and push application id that we will get from and by using those credentials we can easily send push notification to mobile application or other web.

Example : pushwoosh notification code in php:

    $push_auth = 'XXXXXXXXXXXXXXXX';
    $push_app_id = 'XXXXX-XXXXX';
    $push_debug = false;
    $title = ''; // pushwoosh title
    $banner = ''; // pushwoosh banner
    $send_date = 'now'; // pushwoosh date
    $android_header = '';    // pushwoosh android header 
    $android_custom_icon = '' pushwoosh notification icon;
    sendpush('createMessage', array(
                        'application' =$push_app_id,
                        'auth' =$push_auth,
                        'notifications' =>array(
                                'send_date' =>$send_date,
                                'content' =>$title,
                                'android_custom_icon' =>$android_custom_icon,
                                'android_badges' =>2,
                                'android_vibration' =>1,                
                                'android_priority' => 1,
                                'data' =array('custom' =>'json data'),
    function sendpush($method, $data) {
                $url = '' . $method;
                $request = json_encode(['request' => $data]);
                $ch = curl_init($url);
                curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
                curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
                curl_setopt($ch, CURLOPT_ENCODING, 'gzip, deflate');
                curl_setopt($ch, CURLOPT_HEADER, true);
                curl_setopt($ch, CURLOPT_POST, true);
                curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
                $response = curl_exec($ch);            
                $info = curl_getinfo($ch);
                if (defined('PW_DEBUG') && self::$push_de) {
                    print "[PW] request: $request\n";
                    print "[PW] response: $response\n";
                    print "[PW] info: " . print_r($info, true);
                return $info;

For more information click here

Pankaj Singh Sugara

Author Pankaj Singh Sugara

More posts by Pankaj Singh Sugara