From 92f7dbf86a5bdb42d79cb94928102a582a4639ce Mon Sep 17 00:00:00 2001 From: Zach Banks Date: Thu, 6 Jun 2013 16:34:26 -0700 Subject: [PATCH] Fix uploading: send to multiple people by delimiting with commas --- snaphax.php | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/snaphax.php b/snaphax.php index e3f8933..9c89dc5 100644 --- a/snaphax.php +++ b/snaphax.php @@ -115,6 +115,7 @@ function upload($file_data, $type, $recipients, $time=8) { } if (!is_array($recipients)) $recipients = array($recipients); + $recipients = join(', ', $recipients); $ts = $this->api->time(); $media_id = strtoupper($this->options['username']).time(); $this->api->debug('upload snap data', $file_data); @@ -138,23 +139,21 @@ function upload($file_data, $type, $recipients, $time=8) { ); $this->api->debug('upload result', $result); - foreach ($recipients as $recipient) { - $ts = $this->api->time(); - $result = $this->api->postCall( - '/ph/send', - array( - 'username' => $this->options['username'], - 'timestamp' => $ts, - 'recipient' => $recipient, - 'media_id' => $media_id, - 'time' => $time - ), - $this->auth_token, - $ts, - 0 - ); - $this->api->debug("send to $recipient: " . $result); - } + $ts = $this->api->time(); + $result = $this->api->postCall( + '/ph/send', + array( + 'username' => $this->options['username'], + 'timestamp' => $ts, + 'recipient' => $recipients, + 'media_id' => $media_id, + 'time' => $time + ), + $this->auth_token, + $ts, + 0 + ); + $this->api->debug("send to $recipient: " . $result); return $media_id; }