Skip to content

Commit

Permalink
add Search - Rejections API
Browse files Browse the repository at this point in the history
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
  • Loading branch information
appleboy committed Jan 23, 2013
1 parent acc4cfa commit 8395d03
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 10 deletions.
13 changes: 7 additions & 6 deletions controllers/example.php
Expand Up @@ -15,7 +15,6 @@ public function index()
$this->nexmo->set_format('json');

// **********************************Text Message*************************************

$from = 'xxxxxxxx';
$to = 'xxxxxxx';
$message = array(
Expand Down Expand Up @@ -125,14 +124,16 @@ public function index()
$this->nexmo->d_print($response);
echo "<h3>Response Code: " . $this->nexmo->get_http_status() . "</h3>";
$params = array(
'date' => '2013-01-23',
'to' => '886935082580'
);
$response = $this->nexmo->search_messages(null, $params);
$response = $this->nexmo->search_messages(null, '2013-01-23', '886935082580');
echo "<h1>Search - Messages</h1>";
$this->nexmo->d_print($response);
echo "<h3>Response Code: " . $this->nexmo->get_http_status() . "</h3>";
// ********************************Search - Rejections*********************************
$response = $this->nexmo->search_rejections('2013-01-23', '886935082580');
echo "<h1>Search - Message</h1>";
$this->nexmo->d_print($response);
echo "<h3>Response Code: " . $this->nexmo->get_http_status() . "</h3>";
*/
}
}
Expand Down
38 changes: 34 additions & 4 deletions libraries/nexmo.php
Expand Up @@ -24,10 +24,12 @@ class Nexmo {
public static $update_url = 'http://rest.nexmo.com/number/update';
public static $message_url = 'http://rest.nexmo.com/search/message';
public static $messages_url = 'http://rest.nexmo.com/search/messages';
public static $rejections_url = 'http://rest.nexmo.com/search/rejections';

private $_url_array = array('balance_url', 'pricing_url', 'account_url',
'number_url', 'top_up_url', 'search_url', 'buy_url',
'update_url', 'cancel_url', 'message_url', 'messages_url');
'update_url', 'cancel_url', 'message_url', 'messages_url',
'rejections_url');

// codeigniter instance
private $_ci;
Expand Down Expand Up @@ -358,9 +360,11 @@ public function search_message($id = null)
* after submission for real-time delivery notification implement our DLR call back.
*
* @param string
* @param string
* @param string
* return json or xml
*/
public function search_messages($ids = array(), $params = array())
public function search_messages($ids = array(), $date = null, $to = null)
{
$options = array(
CURLOPT_HTTPHEADER => array("Accept: application/" . $this->_format),
Expand All @@ -374,13 +378,39 @@ public function search_messages($ids = array(), $params = array())
$_url = self::$messages_url . $url_string;
}

if (isset($params) and is_array($params)) {
if (isset($date) and isset($to)) {
$params = array(
'date' => $date,
'to' => $to
);
$_url = self::$messages_url;
}
echo $_url;

return $this->request('get', $_url, $params, $options);
}

/**
* Search - Rejections
* Search rejected messages. Please note a message become searchable a few minutes after submission.
*
* @param string
* @param string
* return json or xml
*/
public function search_rejections($date = null, $to = null)
{
$options = array(
CURLOPT_HTTPHEADER => array("Accept: application/" . $this->_format),
);

$params = array(
'date' => $date,
'to' => $to
);

return $this->request('get', self::$rejections_url, $params, $options);
}

/**
* request data
* Connect to Nexmo URL API
Expand Down

0 comments on commit 8395d03

Please sign in to comment.