Prowl\Message::addApiKey PHP Method

addApiKey() public method

This method uses a fluent interface.
public addApiKey ( string $sKey ) : Message
$sKey string An valid api key.
return Message
    public function addApiKey($sKey)
    {
        if (is_string($sKey)) {
            $this->aApiKeys[] = (string) $sKey;
        } else {
            throw new \InvalidArgumentException('The param was not a string.');
        }
        return $this;
    }

Usage Example

Ejemplo n.º 1
0
 protected function send(MessageInterface $message, RecipientInterface $recipient)
 {
     $oProwl = new Connector();
     $oMsg = new Message();
     try {
         $oProwl->setIsPostRequest(true);
         $oMsg->setPriority(0);
         $oProwl->setFilterCallback(function ($sText) {
             return $sText;
         });
         $oMsg->addApiKey($recipient->getInfo('prowl_app.api_key'));
         $oMsg->setEvent($message->getSubject());
         $oMsg->setDescription($message->getContent());
         $oMsg->setApplication($this->appName);
         $oResponse = $oProwl->push($oMsg);
         if ($oResponse->isError()) {
             $this->errors[] = $oResponse->getErrorAsString();
         }
     } catch (\InvalidArgumentException $oIAE) {
         $this->errors[] = $oIAE->getMessage();
     } catch (\OutOfRangeException $oOORE) {
         $this->errors[] = $oOORE->getMessage();
     }
 }
All Usage Examples Of Prowl\Message::addApiKey