Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

change return format for postMessage/postMessages; bump version

  • Loading branch information...
commit 5113ba31e717a6bbf3de8862e81aacd03fb9c1af 1 parent 5fdc141
Alexander Shapiotko thousandsofthem authored
14 IronMQ.class.php
@@ -6,7 +6,7 @@
6 6 * @link https://github.com/iron-io/iron_mq_php
7 7 * @link http://www.iron.io/products/mq
8 8 * @link http://dev.iron.io/
9   - * @version 1.3.0
  9 + * @version 1.3.1
10 10 * @package IronMQPHP
11 11 * @copyright Feel free to copy, steal, take credit for, or whatever you feel like doing with this code. ;)
12 12 */
@@ -117,7 +117,7 @@ public function asArray() {
117 117
118 118 class IronMQ extends IronCore {
119 119
120   - protected $client_version = '1.3.0';
  120 + protected $client_version = '1.3.1';
121 121 protected $client_name = 'iron_mq_php';
122 122 protected $product_name = 'iron_mq';
123 123 protected $default_values = array(
@@ -230,7 +230,7 @@ public function clearQueue($queue_name) {
230 230 * @param string $queue_name Name of the queue.
231 231 * @param string $message
232 232 * @param array $properties
233   - * @return mixed
  233 + * @return string id
234 234 */
235 235 public function postMessage($queue_name, $message, $properties = array()) {
236 236 $msg = new IronMQ_Message($message, $properties);
@@ -241,7 +241,8 @@ public function postMessage($queue_name, $message, $properties = array()) {
241 241 $queue = rawurlencode($queue_name);
242 242 $url = "projects/{$this->project_id}/queues/$queue/messages";
243 243 $res = $this->apiCall(self::POST, $url, $req);
244   - return self::json_decode($res);
  244 + $decoded = self::json_decode($res);
  245 + return $decoded->ids[0];
245 246 }
246 247
247 248 /**
@@ -259,7 +260,7 @@ public function postMessage($queue_name, $message, $properties = array()) {
259 260 * @param string $queue_name Name of the queue.
260 261 * @param array $messages array of messages, each message same as for postMessage() method
261 262 * @param array $properties array of message properties, applied to each message in $messages
262   - * @return mixed
  263 + * @return array $ids
263 264 */
264 265 public function postMessages($queue_name, $messages, $properties = array()) {
265 266 $req = array(
@@ -273,7 +274,8 @@ public function postMessages($queue_name, $messages, $properties = array()) {
273 274 $queue = rawurlencode($queue_name);
274 275 $url = "projects/{$this->project_id}/queues/$queue/messages";
275 276 $res = $this->apiCall(self::POST, $url, $req);
276   - return self::json_decode($res);
  277 + $decoded = self::json_decode($res);
  278 + return $decoded->ids;
277 279 }
278 280
279 281 /**
BIN  iron_mq.phar
Binary file not shown
8 simpleTest.php
@@ -9,9 +9,13 @@
9 9 $ironmq->ssl_verifypeer = false;
10 10
11 11 for ($i = 0; $i < 10; $i++){
12   - echo "Post message..\n";
  12 + echo "Post message:\n";
13 13 $res = $ironmq->postMessage("test_queue", "Test Message $i");
14   - print_r($res);
  14 + var_dump($res);
  15 +
  16 + echo "Post messages:\n";
  17 + $res = $ironmq->postMessages("test-queue-multi", array("Test Message $i", "Test Message $i-2"));
  18 + var_dump($res);
15 19
16 20 echo "Get message..\n";
17 21 $message = $ironmq->getMessage("test_queue");

0 comments on commit 5113ba3

Please sign in to comment.
Something went wrong with that request. Please try again.