POST /send
This api is used for sending a notification request from your server to PushPrime server, please note that this call should be signed using the token as mentioned in the Authentication Section.
POST /send
Parameters
Name | Type | Description |
---|---|---|
notification_title | String | (Required) Title of the notification to be sent |
notification_description | String | (Required) Message of the notification that you want to send. |
notification_url | URL | (Required) Url of the notification, after user clicks on the notification they will be taken to this url. |
notification_icon | URL | (Optiona) Url of the icon file you want to show up with this notification. If you don't send the notification_icon with request, than the default icon from your website on PushPrime will be used. |
Above mentioned parameters are enough if you want to target all of the users or want to send a broadcast, following table defines the parameters which can be used to send targeted notifications.
Name | Type | Description |
---|---|---|
advanced_targeting | String | Send "true" if you want to use any targeting criteria such as direct or segmented. Please note that the value needs to be string and not boolean. |
target_user_condition | Int | 0 if you want to target users not included in the value defined by target_user_value, 1 if you want to target users included in the value defined by target_user_value |
target_user_value | String | Id of the user you want to include or exclude, you can define multiple users by separating them by comma |
target_segment_condition | Int | 0 if you want to target segments not included in the value defined by target_segment_value, 1 if you want to target users included in the value defined by target_segment_value |
target_segment_value | String | Id of the segment you want to include or exclude, you can define multiple segments by separating them by comma |
Example
$apiUrl = 'https://pushprime.com/api/send';
$fields = array(
'notification_title' => urlencode($title),
'notification_description' => urlencode($body),
'notification_url' => urlencode($url),
);
$fields_string = "";
foreach ($fields as $key => $value) {
$fields_string .= $key . '=' . $value . '&';
}
rtrim($fields_string, '&');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $apiUrl);
curl_setopt($ch, CURLOPT_POST, count($fields));
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string);
curl_setopt($ch,CURLOPT_HTTPHEADER, array('token: '.$apiKey));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
curl_close($ch);
After processing your request, PushPrime server will return success or fail status depending on what happened with the request.
In case of a successful API call
{
"status": "success"
}
In case of a successful API call
{
"status": "fail",
"msg": "String containing the reason for failure"
}