added text search into base api
This commit is contained in:
parent
c72e2b06e1
commit
709c096b40
5 changed files with 52 additions and 1 deletions
6
.idea/vcs.xml
generated
Normal file
6
.idea/vcs.xml
generated
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
|
@ -12,7 +12,8 @@
|
||||||
"homepage": "http://joshtronic.com"
|
"homepage": "http://joshtronic.com"
|
||||||
}],
|
}],
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=5.3.0"
|
"php": ">=5.3.0",
|
||||||
|
"phpunit/phpunit": "4.0.*"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"satooshi/php-coveralls": "dev-master"
|
"satooshi/php-coveralls": "dev-master"
|
||||||
|
@ -20,4 +21,5 @@
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {"joshtronic\\": "src/"}
|
"psr-4": {"joshtronic\\": "src/"}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
namespace joshtronic;
|
namespace joshtronic;
|
||||||
|
|
||||||
|
use SebastianBergmann\Exporter\Exception;
|
||||||
|
|
||||||
class GooglePlaces
|
class GooglePlaces
|
||||||
{
|
{
|
||||||
public $client = '';
|
public $client = '';
|
||||||
|
@ -24,6 +26,9 @@ class GooglePlaces
|
||||||
public $placeid = null;
|
public $placeid = null;
|
||||||
public $reference = null;
|
public $reference = null;
|
||||||
public $opennow = null;
|
public $opennow = null;
|
||||||
|
//added these for text search.
|
||||||
|
public $textsearch = null;
|
||||||
|
public $query = null;
|
||||||
|
|
||||||
public $subradius = null;
|
public $subradius = null;
|
||||||
public $getmax = true;
|
public $getmax = true;
|
||||||
|
@ -212,6 +217,14 @@ class GooglePlaces
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
//added this for text search
|
||||||
|
case 'textsearch':
|
||||||
|
if(!isset($parameters['query'])){
|
||||||
|
|
||||||
|
throw new Exception('You must specify the string you want to search for');
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -240,6 +253,12 @@ class GooglePlaces
|
||||||
$querystring .= '&';
|
$querystring .= '&';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// added this to remove spaces from text search
|
||||||
|
if(preg_match('/\s/',$value)){
|
||||||
|
|
||||||
|
$value = str_replace(' ', '+', $value);
|
||||||
|
}
|
||||||
|
|
||||||
$querystring .= $variable . '=' . $value;
|
$querystring .= $variable . '=' . $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -247,6 +266,7 @@ class GooglePlaces
|
||||||
|
|
||||||
if ($this->output == 'json')
|
if ($this->output == 'json')
|
||||||
{
|
{
|
||||||
|
|
||||||
$response = json_decode($response, true);
|
$response = json_decode($response, true);
|
||||||
|
|
||||||
if ($response === null)
|
if ($response === null)
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
require '../vendor/autoload.php';
|
||||||
|
|
||||||
require_once '../src/GooglePlaces.php';
|
require_once '../src/GooglePlaces.php';
|
||||||
require_once '../src/GooglePlacesClient.php';
|
require_once '../src/GooglePlacesClient.php';
|
||||||
|
|
||||||
|
|
||||||
class GooglePlacesTest extends PHPUnit_Framework_TestCase
|
class GooglePlacesTest extends PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
private $places;
|
private $places;
|
||||||
|
|
20
tests/Test.php
Normal file
20
tests/Test.php
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Created by IntelliJ IDEA.
|
||||||
|
* User: dylanaird
|
||||||
|
* Date: 9/2/17
|
||||||
|
* Time: 3:13 PM
|
||||||
|
*/
|
||||||
|
|
||||||
|
require '../vendor/autoload.php';
|
||||||
|
|
||||||
|
require_once '../src/GooglePlaces.php';
|
||||||
|
require_once '../src/GooglePlacesClient.php';
|
||||||
|
|
||||||
|
|
||||||
|
$google_places = new joshtronic\GooglePlaces('AIzaSyCBadIpHu7WgpO0IXGKZw143orleCgi_A4');
|
||||||
|
|
||||||
|
$google_places->query = "Shop 111 Epping Plaza High Street";
|
||||||
|
$results = $google_places->textsearch();
|
||||||
|
|
||||||
|
highlight_string("<?php\n\$data =\n" . var_export($results, true) . ";\n?>");
|
Loading…
Add table
Add a link
Reference in a new issue