Php 通过API的Android推送通知
我使用一个信号API进行推送通知。我想知道如何发送带有值(Confirm=1,Deny=0)的按钮,以便从通知屏幕发布它。我无法通过应用程序发送操作按钮。我想在数据库中发布操作按钮的值。请帮忙 这是我的密码Php 通过API的Android推送通知,php,android,api,onesignal,Php,Android,Api,Onesignal,我使用一个信号API进行推送通知。我想知道如何发送带有值(Confirm=1,Deny=0)的按钮,以便从通知屏幕发布它。我无法通过应用程序发送操作按钮。我想在数据库中发布操作按钮的值。请帮忙 这是我的密码 function sendMessage(){ $heading=array( "en" => 'TEST' ); $content = array( "en" => 'TEST.' );
function sendMessage(){
$heading=array(
"en" => 'TEST'
);
$content = array(
"en" => 'TEST.'
);
$hashes_array = array();
array_push($hashes_array, array(
"id" => "1",
"text" => "Confirm",
"icon" => "http://i.imgur.com/N8SN8ZS.png",
"url" => "https://yoursite.com"
));
array_push($hashes_array, array(
"id" => "0",
"text" => "Deny",
"icon" => "http://i.imgur.com/N8SN8ZS.png",
"url" => "https://yoursite.com"
));
$fields = array(
'app_id' => "xxxxxxx-xxxxxxx-45b8-97d4-02982b59c14f",
'include_player_ids' => array($GLOBALS['one_signal_id']),
'data' => array("Status" => 200),
'small_icon' => 'https://lh3.googleusercontent.com/TzYz9McRVy8fD_WnpKiCK5anw20So6eyPR9ti-LwTd_QIer8BpAg8cMkRoO4sUv2xCDw=w300-rw',
'large_icon' => 'https://lh3.googleusercontent.com/TzYz9McRVy8fD_WnpKiCK5anw20So6eyPR9ti-LwTd_QIer8BpAg8cMkRoO4sUv2xCDw',
'headings' => $heading,
'contents' => $content,
'web_buttons' => $hashes_array
);
$fields = json_encode($fields);
// print("\nJSON sent:\n");
// print($fields);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://onesignal.com/api/v1/notifications");
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json; charset=utf-8',
'Authorization: Basic xxxxxxxxxxxxxxxxxxxxxx5NjktMjRkZWM0ZjFhMjZl'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
$response = curl_exec($ch);
curl_close($ch);
return $response;
}
$response = sendMessage();
等等,您使用的是PHP android端还是Web服务器端?Web服务器端。页面是notification.phpwait,您使用的是PHP android端还是Web服务器端?Web服务器端。页面名为notification.php