function sendMessage($type, $title, $body, $sourceUrl)
 {
     if (version_compare(PHP_VERSION, '5.3.0') >= 0) {
         $oMsg = new \Prowl\Message();
         $oMsg->addApiKey($this->_apikey);
         $oMsg->setApplication($this->_appName);
         $oMsg->setEvent($title);
         $oMsg->setDescription($body);
         $oFilter = new \Prowl\Security\PassthroughFilterImpl();
         $this->prowlObj->setFilter($oFilter);
         $this->prowlObj->setIsPostRequest(true);
         $this->prowlObj->push($oMsg);
     }
     # if
 }
Beispiel #2
0
 public function testDefaultMessageWithClosure()
 {
     $oConnector = new \Prowl\Connector();
     $oConnector->setProviderKey($this->aConfig['providerkey']);
     $oMessage = new \Prowl\Message();
     $oMessage->addApiKey($this->aConfig['apikey']);
     $oMessage->setApplication("Unit Test");
     $oMessage->setPriority(0);
     $oMessage->setEvent("Unit Test");
     $oMessage->setDescription("Unit Test testDefaultMessageWithClosure");
     $oMessage->setFilterCallback(function ($sContent) {
         return $sContent;
     });
     $oResponse = $oConnector->push($oMessage);
     $this->assertFalse($oResponse->isError());
 }
Beispiel #3
0
    });
    // or set a filter instance:
    // $oFilter = new \Prowl\Security\PassthroughFilterImpl();
    // $oProwl->setFilter($oFilter);
    /*
     * Both, the closure and the instance, can be passed to the connector
     * or to each message. Setting it at the connector passes the closure or the instance down
     * to each message on push() execution - but only if the message has neither of them set.
     */
    $oProwl->setIsPostRequest(true);
    $oMsg->setPriority(0);
    // You can ADD up to 5 api keys
    // This is a Test Key, please use your own.
    $oMsg->addApiKey('e0bf09a4cc20ae0bcd63b30b19031ef59a458634');
    $oMsg->setEvent('My Event!');
    // These are optional:
    $oMsg->setDescription('My Event description.');
    $oMsg->setApplication('My Custom App Name.');
    $oResponse = $oProwl->push($oMsg);
    if ($oResponse->isError()) {
        print $oResponse->getErrorAsString();
    } else {
        print "Message sent." . PHP_EOL;
        print "You have " . $oResponse->getRemaining() . " Messages left." . PHP_EOL;
        print "Your counter will be resetted on " . date('Y-m-d H:i:s', $oResponse->getResetDate()) . PHP_EOL;
    }
} catch (\InvalidArgumentException $oIAE) {
    print $oIAE->getMessage();
} catch (\OutOfRangeException $oOORE) {
    print $oOORE->getMessage();
}