Send to an Individual Subscriber
Posted in General by Adenilson Soares Wed Jan 24 2018 16:23:24 GMT+0000 (Coordinated Universal Time)·Viewed 1,240 times
I don“t know whats is wrong. Im trying to senda test to a subscribed user using php. could you help me
<?php
$title = 'Titulo de Test';
$message = 'Test';
$url = 'http://segsoftware.com.br';
$subscriberId = '919fd2eec1c0e0304655a355a62e3fc0';
$apiToken = 'df06e4a9c1507e4f73945928375131d9';
$curlUrl = 'https://pushcrew.com/api/v1/send/individual/';
//set POST variables
$fields = array(
'title' => $title,
'message' => $message,
'url' => $url,
'subscriber_id' => $subscriberId
);
$httpHeadersArray = Array();
$httpHeadersArray[] = 'Authorization: key='.$apiToken;
//open connection
$ch = curl_init();
//set the url, number of POST vars, POST data
curl_setopt($ch, CURLOPT_URL, $curlUrl);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($fields));
curl_setopt($ch, CURLOPT_HTTPHEADER, $httpHeadersArray);
//execute post
$result = curl_exec($ch);
$resultArray = json_decode($result, true);
if($resultArray['status'] == 'success') {
//success
//echo $resultArray['request_id']; //ID of Notification Request
echo("sucess");
}
else if($resultArray['status'] == 'failure') {
//failure
echo("erro1");
}
else {
//failure
echo("erro2 " . $result);
}
//echo($subscriberId);
?>