Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function sendMessage($app_id, $api_key, $message)
- {
- $content = array("en" => $message);
- $fields = array(
- 'app_id' => $app_id,
- 'included_segments' => array('All'),
- 'data' => array("foo" => "bar"),
- 'contents' => $content);
- $fields = json_encode($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 ' . $api_key));
- 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;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement