/** * Pushes a message to the given api key. * * @param \Prowl\Message $oMessage * @return \Prowl\Response */ public function push(\Prowl\Message $oMessage) { // Messages must be sent as post $this->setIsPostRequest(true); $oMessage->validate(); if ($oMessage->getFilterCallback() == null) { if ($this->getFilterCallback() != null) { $oMessage->setFilterCallback($this->getFilterCallback()); } } // if the previous routine did not set a callback, try to set the filter instance. if ($oMessage->getFilterCallback() == null) { if ($oMessage->getFilter() == null) { if ($this->getFilter() != null) { $oMessage->setFilter($this->getFilter()); } else { throw new \RuntimeException("No filter found. " . "Please set a filter either in the message or in the connector"); } } } $aParams['apikey'] = $oMessage->getApiKeysAsString(); $aParams['providerkey'] = $this->sProviderKey; $aParams['application'] = $oMessage->getApplication(); $aParams['event'] = $this->filter($oMessage, $oMessage->getEvent()); $aParams['description'] = $this->filter($oMessage, $oMessage->getDescription()); $aParams['priority'] = $oMessage->getPriority(); if ($oMessage->getUrl() != null) { $aParams['url'] = $oMessage->getUrl(); } array_map(create_function('$sAryVal', 'return str_replace("\\n","\\n", $sAryVal);'), $aParams); $sContextUrl = $this->sPushEndpoint; if (!$this->bIsPostRequest) { $sContextUrl .= '?'; } $sParams = http_build_query($aParams); $sReturn = $this->execute($sContextUrl, $this->bIsPostRequest, $sParams); $this->oLastResponse = \Prowl\Response::fromResponseXml($sReturn); return $this->oLastResponse; }