Пример #1
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());
 }
Пример #2
0
// $oProwl->setProviderKey('MY_PROVIDER_KEY');
try {
    // You can choose to pass a callback
    $oProwl->setFilterCallback(function ($sText) {
        return $sText;
    });
    // 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;
    }