OneSignal Push Notification PHP API

Today, We want to share with you OneSignal Push Notification PHP API.In this post we will show you Create Onesignal Push Notification in PHP, hear for Adding Push Notification in PHP With OneSignal we will give you demo and example for implement.In this post, we will learn about OneSignal Push Notification Send to Specific User in PHP with an example.

OneSignal Push Notification PHP API

There are the Following The simple About OneSignal Push Notification PHP API Full Information With Example and source code.

As I will cover this Post with live Working example to develop Push Notification PHP via Onesignal, so the OneSignal how to send Push to specific device for this example is following below.

onesignal php push notification panel

onesignal features

  • Unlimited Mobile Push
  • Web Push Up to 30K Subscribers
  • Unlimited Segmentation
  • Delivery Scheduling
  • Emojis and Images
  • Localization
  • A/B Testing
  • Real-Time Analytics
OneSignal Push Notification PHP API Examples
OneSignal Push Notification PHP API Examples

Step 1: Include header Part

index.html




    onesignal - Register Notification - Pakainfo.com



    
    


Step 2: Include header Part

Ajax Call Save playerId

    
    

Step 3: onesignal Add New Subscribers

add_user_all_subs.php


Step 4: onesignal Send Push Notification Code

sendpushnotification.php

 'Welcome To - pakainfo.com free Download Source code'
    );
    $beutiful_template_array = array();
    array_push($beutiful_template_array, array(
        "id" => "file-button",
        "text" => "pakainfo",
        "icon" => "http://i.imgur.com/N8SN8ZS.png",
        "url" => "https://www.pakainfo.com/example/"
    ));
    array_push($beutiful_template_array, array(
        "id" => "file-button-2",
        "text" => "Pakainfo2",
        "icon" => "http://i.imgur.com/N8SN8ZS.png",
        "url" => "https://www.pakainfo.com/example/"
    ));
    $fields = array(
        'app_id' => "cd9e4242-cd78-9898-b181-0ef50f0jd43d",
        'included_segments' => array(
            'All'
        ),
        'data' => array(
            "foo" => "bar"
        ),
        'contents' => $content,
        'web_buttons' => $beutiful_template_array
    );
    
    $fields = json_encode($fields);
    print("\nJSON sent:\n");
    print($fields);
    
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, "https://onesignal.com/api/v1/push_onesignal_message");
    curl_setopt($ch, CURLOPT_HTTPHEADER, array(
        'Content-Type: application/json; charset=utf-8',
        'Authorization: Basic JDKiNzU9PLKtN2M5OS00FJK7LTg6YWYtYTY1OTAzMJS8YzI8'
    ));
    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;
}

$results = sendPushNotification();

var_dump($results);

?>
Angular 6 CRUD Operations Application Tutorials

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about OneSignal Push Notification PHP API.
I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Leave a Comment