How to Send Push Notification Via CURL PHP PushWoosh

Send Push Notification via PHP cURL API. A simple API call to create message pushwoosh.

This is a code snippet to send a message via PHP cURL through the PushWoosh API. 

define('PW_AUTH', 'TOKEN');
define('PW_APPLICATION', 'APP_ID');
define('PW_DEBUG', false);

function pwCall($method, $data) {
  
    $url = 'https://cp.pushwoosh.com/json/1.3/' . $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);
    curl_close($ch);
 
    if (defined('PW_DEBUG') && PW_DEBUG) {
        print "[PW] request: $request\n";
        print "[PW] response: $response\n";
        print '[PW] info: ' . print_r($info, true);
    }
  
}

pwCall('createMessage', array(
    'application' => PW_APPLICATION,
    'auth' => PW_AUTH,
    'notifications' => array(
            array(
                'send_date' => 'now',
                'content' => "My Content Push Notification",
                'devices' => array("device_token", "device_token"),

            )
        )
    )
);