開発 OneSignal Send based on filters/tags – Create notification
‘Click here’,
);
$fields = array(
‘app_id’ => “3b154286-ad8f-4802-b820-98b9f185306b”,
‘filters’ => array(array(“field” => “tag”, “key” => “mother_tongue”, “relation” => “=”, “value” => “Bingo”)),
‘data’ => array(“foo” => “bar”),
‘url’ => ‘https://onlinelanguage.info/?page_id=1204’,
‘contents’ => $content
);
$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 ZDZkZTM5YTctZDgzZS00ODI4LWEyMGMtNzY0NDgyZjZjYmIw’));
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();
$return[“allresponses”] = $response;
$return = json_encode( $return);
print(“\n\nJSON received:\n”);
print($return);
print(“\n”);
edit_post_link( );
?>