/** * Checks the server for messages and returns their results. * * @param array $options * * @return array */ public function checkMessages(array $options = []) { $start = array_key_exists('start', $options) ? $options['start'] : 0; $end = array_key_exists('end', $options) ? $options['end'] : 25; $rawMessages = $this->plivo->get_messages(['offset' => $start, 'limit' => $end]); $incomingMessages = []; foreach ($rawMessages['objects'] as $rawMessage) { $incomingMessage = $this->createIncomingMessage(); $this->processReceive($incomingMessage, $rawMessage); $incomingMessages[] = $incomingMessage; } return $incomingMessages; }
/** * Get Message details */ public function getMessages() { return $this->plivo->get_messages(); }
<?php require 'vendor/autoload.php'; use Plivo\RestAPI; $auth_id = "Your AUTH_ID"; $auth_token = "Your AUTH_TOKEN"; $p = new RestAPI($auth_id, $auth_token); // Fetch the details $response = $p->get_messages(); // Print the response print_r($response['response']); // Filter the response $params = array('limit' => '2', 'offset' => '0', 'message_direction ' => 'outbound', 'message_state' => 'sent', 'subaccount' => 'SubAccount_AUTH_ID'); // Fetch the details $response = $p->get_messages($params); // Print the response print_r($response['response']); ?> <!-- Sample Output without Filters ( [api_id] => f9adfd4a-a264-11e4-a2d1-22000ac5040c [meta] => Array ( [limit] => 2 [next] => /v1/Account/XXXXXXXXXXXXXXX/Message/?message_state=sent&limit=2&offset=2&message_direction+=outbound [offset] => 0 [previous] => [total_count] => 70 ) [objects] => Array ( [0] => Array (