Overview on what I’m looking to achieve:
A website which users can login (with different permissions defined by a database) and be sent notifications via OneSignal when a status of an order changes.
Currently I have the login system finished and users are placed into the correct segments on OneSignal (e.g. Suppliers). What I’m looking to do is trigger a notification to appear for all ‘Suppliers’ when an order’s status is updated.
Any ideas on how I can go about this? I’ve looked through all the documentation multiple times so please no comments just saying to do that.
Thanks in advance.
\<?php function sendMessage(){ $content = array( "en" =\> 'Test Message' ); $fields = array( 'app\_id' =\> "1a95c98a-9349-4876-b9ce-981893b7bf42", 'included\_segments' =\> array('Suppliers'), 'data' =\> array("userType" =\> "suppliers"), '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 NGEwMGZmMjItY2NkNy0xMWUzLTk5ZDUtMDAwYzI5NDBlNjJj')); 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"); ?\>