Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries. Thanks for all your past and future contributions.

Using PHP and cURL to send a notification using Notification Service API

From Wiki
Jump to: navigation, search
Article Metadata
Created: isalento (17 Jan 2011)
Last edited: hamishwillee (21 Nov 2013)


With the Notifications API you can enable Push messages for Qt applications. Notifications API consists of two major parts Client API and Service API. Client API is to be used on a device with Qt. It handles registration and message passing between device and Notifications Server. Notifications Service API is REST API that handles the communication between your service and Notifications Server.

See more information on!developers-guides/nokia-notifications.html

You can include the code below to your Web Page or run it directly from console, by saving the file as notification.php and running it “php notification.php”.


$serviceId = "<service id>";
$serviceSecret = "<service secret>";
$nid = urlencode("<notification id of the application>");
$url = "".$nid."/";
$args = '&payload=hello&ctype='.urlencode("text/plain");
$session = curl_init($url);
curl_setopt ($session, CURLOPT_POST, true);
//POST Body
curl_setopt ($session, CURLOPT_POSTFIELDS, $args);
curl_setopt($session, CURLOPT_HEADER, true);
curl_setopt($session, CURLOPT_RETURNTRANSFER, false);
curl_setopt($session, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($session, CURLOPT_VERBOSE, true); //verbose
curl_setopt($session, CURLOPT_HEADER, true); //display headers
curl_setopt($session, CURLOPT_USERPWD, $serviceId.':'.$serviceSecret);
This page was last modified on 21 November 2013, at 07:20.
88 page views in the last 30 days.