<?PHP
function sendMessage() {
    $content      = array(
        "en" => 'Test Content'
    );
    $fields = array(
        'app_id' => "6b5ae8dd-3b56-4960-9922-f78b61e59499",
        'included_segments' => array(
            'Subscribed Users'
        ),
    //      'include_external_user_ids' => array("6392d91a-b206-4b7b-a620-cd68e32c3a76","76ece62b-bcfe-468c-8a78-839aeaa8c5fa","8e0f21fa-9a5a-4ae7-a9a6-ca1f24294b86"),
    //   'channel_for_external_user_ids' => 'push',
        'data' => array(
            "foo" => "bar"
        ),
        'contents' => $content,
        'headings' => array("en"=>"Test Heading"),
        'big_picture' => 'https://api.iconxtechnologies.in/Arabian_hut/img/logo.jpg',
    );
    
    $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 ZjY1YmM0NjAtMzFmNi00ZTBjLWIwNDYtNTg3MDRhZjMxN2Fl'
    ));
    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);

$data = json_decode($response, true);
print_r($data);
$id = $data['id'];
print_r($id);

print("\n\nJSON received:\n");
print($return);
print("\n");
?>