Added the ability to do a text base search #14
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"
|
||||
}],
|
||||
"require": {
|
||||
"php": ">=5.3.0"
|
||||
"php": ">=5.3.0",
|
||||
"phpunit/phpunit": "4.0.*"
|
||||
},
|
||||
"require-dev": {
|
||||
"satooshi/php-coveralls": "dev-master"
|
||||
|
@ -20,4 +21,5 @@
|
|||
"autoload": {
|
||||
"psr-4": {"joshtronic\\": "src/"}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
namespace joshtronic;
|
||||
|
||||
use SebastianBergmann\Exporter\Exception;
|
||||
|
||||
class GooglePlaces
|
||||
{
|
||||
public $client = '';
|
||||
|
@ -24,6 +26,9 @@ class GooglePlaces
|
|||
public $placeid = null;
|
||||
public $reference = null;
|
||||
public $opennow = null;
|
||||
//added these for text search.
|
||||
public $textsearch = null;
|
||||
public $query = null;
|
||||
|
||||
public $subradius = null;
|
||||
public $getmax = true;
|
||||
|
@ -212,6 +217,14 @@ class GooglePlaces
|
|||
}
|
||||
|
||||
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 .= '&';
|
||||
}
|
||||
|
||||
// added this to remove spaces from text search
|
||||
if(preg_match('/\s/',$value)){
|
||||
|
||||
$value = str_replace(' ', '+', $value);
|
||||
}
|
||||
|
||||
$querystring .= $variable . '=' . $value;
|
||||
}
|
||||
|
||||
|
@ -247,6 +266,7 @@ class GooglePlaces
|
|||
|
||||
if ($this->output == 'json')
|
||||
{
|
||||
|
||||
$response = json_decode($response, true);
|
||||
|
||||
if ($response === null)
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
<?php
|
||||
|
||||
require '../vendor/autoload.php';
|
||||
|
||||
require_once '../src/GooglePlaces.php';
|
||||
require_once '../src/GooglePlacesClient.php';
|
||||
|
||||
|
||||
class GooglePlacesTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
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