This endpoint is used to send notification. The request method of this call needs to be "POST".
https://api2.pushassist.com/notifications/
| Parameter Name | Description |
|---|---|
| title | Notification title. |
| message | Notification message |
| redirect_url | Target url to be associated with the notification (Optional). |
| image | https:// OR http://target-url image (250px X 250px) (Optional). |
| big_image | https:// OR http://target-url Banner image (400px X 400px) (Optional). |
function send_notification($response_array){
$url = 'https://api2.pushassist.com/notifications/';
$headers = array(
'X-Auth-Token: Your API Key',
'X-Auth-Secret: Your SECRET Key',
'Content-Type: application/json'
);
$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_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($response_array));
curl_setopt($ch, CURLOPT_SSLVERSION, 4);
$result = curl_exec($ch);
if ($result === FALSE) {
die('Curl failed: ' . curl_error($ch));
}
curl_close($ch);
$result_arr = json_decode($result, true);
return $result_arr;
}
$response_array = array("notification" => array(
"title" => "Notification Test",
"message" => "Notification Test Message",
"redirect_url" => "",
"image" => "", // full image path / local image path will not work
"big_image" => ""), // full image path / local image path will not work
"utm_params" => array("utm_source" => "", // optional
"utm_medium" => "",
"utm_campaign" => ""),
"segments" => array('YourSegmentName')
);
$response = send_notification($response_array);
if($response['status'] == 'Success'){
echo $response['response_message'];
} else if($response['status'] == 'Error') {
echo $response['error_message'];
} else if($response['error'] != ''){
echo $response['error'];
} else {
echo $response['errors'];
}