About PHPCheck PHP official website
Hook.Notifier is a notification collector, it allows you to send, store and organize useful notifications on your phone from various services.Check Hook.Notifier official website
Our first notification from PHP
The goal is simple here, to receive a test notification from a PHP file.
Curl to our rescue
To communicate with Hook.Notifier, we will need cURL, if it is not already the case, you will need to install the library on your PHP environment, no additional dependencies are required. To know if cURL is installed, look at your
phpinfo(); or try to run the script below, if the cURL functions are not found it means that your environment is not correctly installed.
1. A small PHP script
We have created a simple PHP script that includes all the parameters that Hook.Notifier makes available to us. For more information, we refer you to our article Get Started.
Get started with Hook.Notifier
This article aims to introduce you to Hook.Notifier, including its benefits, recommended introductory articles, and developer documentation.
This script can be included in any type of PHP environment, you also don't have to take any precautions regarding your credentials since your script should not be accessible to your site's users. Include it, of course, where you need to trigger a notification.
[[PHP]]// Required $identifier = %_YOUR_IDENTIFIER_%; $key = "%_YOUR_KEY_%"; $object = urlencode("My notification from PHP"); $body = urlencode("Hooray, my notification from PHP has been sent!"); // Optional $tags = "php,test"; $color = urlencode("#7C86B4"); $image = "https://cdn.hooknotifier.com/receive_notification_from_php_header_a7ede2135c.png"; $redirectUrl = "https://hooknotifier.com"; $sound = true; $sendToTeam = false; $preventData = false; $innerData = array( 'author' => '...', 'message' => '...', 'receiver' => '...', // anything you want... ); // Do not touch $parameters = "object=$object&body=$body&tags=$tags&color=$color&image=$image&redirectUrl=$redirectUrl&sendToTeam=$sendToTeam&sound=$sound&preventData=$preventData"; $ch = curl_init("https://moon.hooknotifier.com/$identifier/$key?$parameters"); $payload = json_encode($innerData); curl_setopt($ch, CURLOPT_POSTFIELDS, $payload); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json')); curl_exec($ch); curl_close($ch);
This script simply executes a cURL call to our Hook.Notifier server sending the parameters of your notification. Remember to change your %_YOUR_IDENTIFIER_% and %_YOUR_KEY_% credentials and to vary the different parameters of your notification to suit your needs.
2. Triggering and sending
All you have to do is to trigger the sending of your notification by executing your PHP script. You should receive your notification in the second!
You should now be able to send notifications from your PHP environment, whether we are talking about Wordpress, Symfony, Laravel or any type of PHP technology, everything should work the same.
Send notifications about your form submissions, inject data in the subject or body of your notification, retrieve statistics... The possibilities are endless with Hook.Notifier. Be creative!
If you like this article, feel free to connect with us on Twitter.
If you have any questions or special requests, such as needing clarification on the terms discussed in this article, more information on a specific part, or additional articles and tutorials, please feel free to provide feedback through the widget below.