From 6b7145763ae5f8bb4f44c6ef62909e819e1e4055 Mon Sep 17 00:00:00 2001 From: Mariano Conti Date: Wed, 13 Aug 2014 15:17:12 -0300 Subject: [PATCH 1/4] Updated to send links with Yos --- README.md | 16 +++++++++++++++- yo.php | 14 +++++++++----- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index d0140ee..c10fa99 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,13 @@ yo-php Send Yos from your PHP app with 2 lines of code. -## Example +## New in Version 0.2 + +Send links with your Yos. + +When you send a link along with your Yo and the user taps on it, it'll open a browser to your link instead of opening the Yo app. + +## Examples ```php all(); +// Send a Yo with a link to all your subscribers +$link = 'http://www.mysuperawesomewebpage.com/'; +$yo->all($link); + // Send a Yo to one user $yo->user('USERNAME'); +// Send a Yo with a link to one user +$link = 'http://www.mysuperawesomewebpage.com/user/USERNAME/'; +$yo->user('USERNAME', $link); + // Get number of subscribers $count = $yo->subscribers(); // returns an int or false ?> diff --git a/yo.php b/yo.php index fb3d282..efe9e64 100644 --- a/yo.php +++ b/yo.php @@ -14,14 +14,14 @@ public function __construct($apiKey) { $this->_apiKey = $apiKey; } - public function user($username) { + public function user($username, $link = '') { if ($username != '') { - $this->processRequest($username); + $this->processRequest($username, $link); } } - public function all() { - $this->processRequest(); + public function all($link = '') { + $this->processRequest($username = '', $link); } public function subscribers() { @@ -50,7 +50,7 @@ public function subscribers() { return false; } - private function processRequest($username = '') { + private function processRequest($username = '', $link = '') { $postFields = array( 'api_token' => $this->_apiKey ); @@ -62,6 +62,10 @@ private function processRequest($username = '') { $url = $this->urls['user']; } + if ($link != '') { + $postFields['link'] = $link; + } + $options = array( CURLOPT_URL => $url, CURLOPT_RETURNTRANSFER => true, From d401637380deb665e0f99428f29691a8f928e6a4 Mon Sep 17 00:00:00 2001 From: Mariano Conti Date: Mon, 27 Oct 2014 17:48:35 -0300 Subject: [PATCH 2/4] Can send location with Yo --- yo.php | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/yo.php b/yo.php index efe9e64..b1a1039 100644 --- a/yo.php +++ b/yo.php @@ -14,14 +14,14 @@ public function __construct($apiKey) { $this->_apiKey = $apiKey; } - public function user($username, $link = '') { + public function user($username, $link = null, $location = null) { if ($username != '') { - $this->processRequest($username, $link); + $this->processRequest($username, $link, $location); } } - public function all($link = '') { - $this->processRequest($username = '', $link); + public function all($link = null) { + $this->processRequest($username = null, $link, null); } public function subscribers() { @@ -50,21 +50,25 @@ public function subscribers() { return false; } - private function processRequest($username = '', $link = '') { + private function processRequest($username = null, $link = null, $location = null) { $postFields = array( 'api_token' => $this->_apiKey ); $url = $this->urls['all']; - if ($username != '') { + if ($username != null) { $postFields['username'] = $username; $url = $this->urls['user']; } - if ($link != '') { + if ($link != null) { $postFields['link'] = $link; } + + if ($location != null) { + $postFields['location'] = $location; + } $options = array( CURLOPT_URL => $url, From cc535f57969d7bf2a6dcd5925df82502ece8caed Mon Sep 17 00:00:00 2001 From: Mariano Conti Date: Mon, 27 Oct 2014 17:48:35 -0300 Subject: [PATCH 3/4] Can send location with Yo --- README.md | 10 ++++++++++ yo.php | 24 +++++++++++++++++------- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index c10fa99..0daff22 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,12 @@ yo-php Send Yos from your PHP app with 2 lines of code. +## New in Version 0.3 + +Send your location! + +This only works when sending a Yo to an individual user, not to all your subscribers at once. + ## New in Version 0.2 Send links with your Yos. @@ -37,6 +43,10 @@ $yo->user('USERNAME'); $link = 'http://www.mysuperawesomewebpage.com/user/USERNAME/'; $yo->user('USERNAME', $link); +// Send a Yo with a location (format is a string like LAT;LNG) +$location = '-34.6158527;-58.4332985'; +$yo->userWithLocation('USERNAME', $location); + // Get number of subscribers $count = $yo->subscribers(); // returns an int or false ?> diff --git a/yo.php b/yo.php index efe9e64..827062a 100644 --- a/yo.php +++ b/yo.php @@ -14,14 +14,20 @@ public function __construct($apiKey) { $this->_apiKey = $apiKey; } - public function user($username, $link = '') { + public function user($username, $link = null) { if ($username != '') { - $this->processRequest($username, $link); + $this->processRequest($username, $link, null); } } - public function all($link = '') { - $this->processRequest($username = '', $link); + public function userWithLocation($username, $location = null) { + if ($username != '') { + $this->processRequest($username, null, $location); + } + } + + public function all($link = null) { + $this->processRequest($username = null, $link, null); } public function subscribers() { @@ -50,21 +56,25 @@ public function subscribers() { return false; } - private function processRequest($username = '', $link = '') { + private function processRequest($username = null, $link = null, $location = null) { $postFields = array( 'api_token' => $this->_apiKey ); $url = $this->urls['all']; - if ($username != '') { + if ($username != null) { $postFields['username'] = $username; $url = $this->urls['user']; } - if ($link != '') { + if ($link != null) { $postFields['link'] = $link; } + + if ($location != null) { + $postFields['location'] = $location; + } $options = array( CURLOPT_URL => $url, From 8c9dfe7cde9854f79415fd54e745de9e0ffcddc4 Mon Sep 17 00:00:00 2001 From: Mariano Conti Date: Sun, 2 Nov 2014 15:36:49 -0300 Subject: [PATCH 4/4] Updated README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0daff22..3920313 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Send Yos from your PHP app with 2 lines of code. Send your location! -This only works when sending a Yo to an individual user, not to all your subscribers at once. +This only works when sending a Yo to an individual user, not to all your subscribers at once. Use method "userWithLocation". ## New in Version 0.2