Exemplo n.º 1
0
 public function testISO8601DateFormatting()
 {
     $message = new Message();
     $message->setScheduledDateFromString('2016-05-24T20:42:06-07:00');
     $this->assertEquals('2016-05-24T20:42:06-0700', $message->getScheduledDateAsString());
 }
Exemplo n.º 2
0
 public function parseMessage($json, Message $message)
 {
     if (empty($json)) {
         return $message;
     }
     $messageBody = json_decode($json, true);
     if (json_last_error() > 0) {
         return $message;
     }
     $message->setId($this->checkArray($messageBody, 'id'));
     $message->setDeviceId($this->checkArray($messageBody, 'deviceId'));
     $message->setFingerprint($this->checkArray($messageBody, 'fingerprint'));
     $message->setContactId($this->checkArray($messageBody, 'contactId'));
     $message->setFinalDestination($this->checkArray($messageBody, 'finalDestination'));
     $message->setFinalSource($this->checkArray($messageBody, 'finalSource'));
     $message->setAddress($this->checkArray($messageBody, 'address'));
     $message->setBcc($this->checkArray($messageBody, 'bcc'));
     $message->setCc($this->checkArray($messageBody, 'cc'));
     $message->setMessageType($this->checkArray($messageBody, 'messageType'));
     $message->setBody($this->checkArray($messageBody, 'body'));
     $message->setBodySize($this->checkArray($messageBody, 'bodySize'));
     $message->setStatusCode($this->checkArray($messageBody, 'statusCode'));
     $message->setHasAttachment($this->checkArray($messageBody, 'hasAttachment'));
     $message->setDeleted($this->checkArray($messageBody, 'deleted'));
     $message->setRead($this->checkArray($messageBody, 'read'));
     $message->setVisible($this->checkArray($messageBody, 'visible'));
     $message->setDateCreatedFromString($this->checkArray($messageBody, 'dateCreated'));
     $message->setDateDeletedFromString($this->checkArray($messageBody, 'dateDeleted'));
     $message->setDateReadFromString($this->checkArray($messageBody, 'dateRead'));
     $message->setScheduledDateFromString($this->checkArray($messageBody, 'scheduledDate'));
     return $message;
 }
Exemplo n.º 3
0
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE. OTHER DEALINGS IN THE SOFTWARE.
 */
require_once $_SERVER['DOCUMENT_ROOT'] . '/../vendor/autoload.php';
use acapps\webhooks\models\Message;
// Retrieve POST Data
$webhookPayload = file_get_contents("php://input");
// Create a new Message Object.
$message = new Message();
// Parse the incoming JSON to our new Message Object.
$message->parseMessageJson($webhookPayload);
// Echo out the pertinant details.
echo sprintf("We received a new message:\nid: %s\nbody: %s:\nfingerprint: %s\nsource: %s\ndestination: %s", $message->getId(), $message->getBody(), $message->getFingerprint(), $message->getFinalSource(), $message->getFinalDestination());
// Example inbound request:
/*
curl -X POST -H "Content-Type: application/json" -H "Cache-Control: no-cache" -d '{"body":"Reply for MONITOR","bodySize":17,"visible":true,"hasAttachment":false,"dateRead":"2015-06-25T14:43:13-07:00","bcc":null,"finalDestination":"8559806848","messageType":"MO","deleted":false,"statusCode":1,"id":614187113839398912,"scheduledDate":null,"fingerprint":"1391524360","messageTransport":5,"contactId":2989191403,"address":"ptn:/6505332635","read":true,"dateCreated":"2015-06-25T14:43:13-07:00","dateDeleted":null,"dateDelivered":null,"cc":null,"finalSource":"4257772200","deviceId":274232703}' "http://localhost:10120/example.php"
*/
// Example output:
/*
We received a new message:
id: 614187113839398912
body: Reply for MONITOR:
fingerprint: 1391524360
source: 4257772200