Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestions for New Features #13

Open
SachinAgarwal1337 opened this issue Mar 7, 2017 · 14 comments
Open

Suggestions for New Features #13

SachinAgarwal1337 opened this issue Mar 7, 2017 · 14 comments

Comments

@SachinAgarwal1337
Copy link
Owner

SachinAgarwal1337 commented Mar 7, 2017

I am open for suggestions for adding new features or enhancements.

Thank you.
Hope you all like this small package.

@1quintana
Copy link

Hello, I am using this package for some of my projects, I wonder if you already worked to get the images from google, because I can not find any method for that.

@SachinAgarwal1337
Copy link
Owner Author

@1quintana I haven't implemented place photos api. I will be implementing it soon.

@jhnferraris
Copy link
Contributor

Have you implemented https://developers.google.com/places/web-service/add-place? Or anyone has implement this feature?

@SachinAgarwal1337
Copy link
Owner Author

@jhnferraris It is implemented. But just a heads up, its deprecated in google places api. Thus it will be removed in future when google stops the api.

@sifang
Copy link

sifang commented Dec 3, 2017

  • 1 for photo

@marcus-at-localhost
Copy link

Here is a half assed implementation of the photo retrieval. I provide it as a gist, since it lacks the error handling and maybe it's bad programming style. I hope this helps @SachinAgarwal1337 to implement it faster, though.

https://gist.github.com/marcus-at-localhorst/7ee1a749bdde56a778360d0e74619a62/revisions

I couldn't use the makeRequest method since the response body is a blob (image data) and it was messing with the response status and error handling.

So I added a new guzzle call in the photomethod, to retrieve the final photo uri (after a redirect).

Test script:

$places = $this->googlePlaces->nearbySearch('34.5134,-85.31736', 50);
$closest = $places->get('results')->first();
$place = array_intersect_key($closest, array_flip(['place_id','photos','vicinity']));
$place_details = $this->googlePlaces->placeDetails($place['place_id']);

foreach($place_details->get('result')['photos'] as $photo){
  $photos[] = $this->googlePlaces->photo($photo['photo_reference'], ['maxheight' => 220]);
}

result:

  0 => string 'https://lh3.googleusercontent.com/p/AF1QipMeSRPyaS9yDfR9AUW_VyRVfg8p_WDTDJDKszxA=s1600-h220' (length=91)
  1 => string 'https://lh3.googleusercontent.com/p/AF1QipMIWLSBHrhvN4G3OgaMs1eHxRbp4Cw2KJpzKpqV=s1600-h220' (length=91)
  2 => string 'https://lh3.googleusercontent.com/p/AF1QipNwMIvw6EVNsJaPj_u16FJbXCm6i8pNs__m_KCn=s1600-h220' (length=91)
  3 => string 'https://lh3.googleusercontent.com/p/AF1QipM8xq4_4EZEVGehgT7nJ4DPUihso9Jdy5IcD5Rl=s1600-h220' (length=91)
  4 => string 'https://lh3.googleusercontent.com/p/AF1QipO49u-XAazQ77y1Lxa4DjXV4lA2EYc_ZHe036_U=s1600-h220' (length=91)
  5 => string 'https://lh3.googleusercontent.com/p/AF1QipPlE6NEYYuvf1lOLa24eknI9UZ_zbnUXyluxerQ=s1600-h220' (length=91)
  6 => string 'https://lh3.googleusercontent.com/p/AF1QipMsFc-_2rqK3aisgQZ7YcyeQl_c6mCXcCqw-Y_r=s1600-h220' (length=91)
  7 => string 'https://lh3.googleusercontent.com/p/AF1QipMVn3ucQKtYzVsTimXEiLn74xEWXu_QtzayaCVz=s1600-h220' (length=91)
  8 => string 'https://lh3.googleusercontent.com/p/AF1QipN2EdqVBnNy1zWOAZolhNTlkHewc1H7TWYs7Xln=s1600-h220' (length=91)
  9 => string 'https://lh3.googleusercontent.com/p/AF1QipMFavT5igltZhK5UNw6_MXQgrnughdyFxiJ9yzQ=s1600-h220' (length=91)

But, I didn't implement the error handling.
Hope that helps.

tl;dr

Photo method without error handling as gist
https://gist.github.com/marcus-at-localhorst/7ee1a749bdde56a778360d0e74619a62/revisions

@SachinAgarwal1337
Copy link
Owner Author

SachinAgarwal1337 commented Feb 21, 2018

@1quintana @sifang @marcus-at-localhorst Place Photo Support Added.

@SachinAgarwal1337
Copy link
Owner Author

@marcus-at-localhorst Thanks for the Gist. It really helped.

@marcus-at-localhost
Copy link

I'm glad it helped.
Interesting how you simplified that additional guzzle call.
I learned something new.

Thanks!

@mits87
Copy link

mits87 commented Apr 3, 2018

Hi, any plans for include functionality of caching results from google?
For instance in redis?

@SachinAgarwal1337
Copy link
Owner Author

@mits87 I feel caching should be part of the application and not package/library. But If there seems to be a need, will surely do add caching.

@mallardduck
Copy link

@SachinAgarwal1337 & @mits87 Maybe it would be cool if the caching feature was optional? I would agree that it feels more like an app level thing than a library concern. SRP extended to the library level would push me to feel like the library's concern should just be interacting with Google APIs.

If it had light & optional support for PSR-6 or PSR-16 Cache that could be kinda neat though. Then, in theory, within an App/Framework the library could just use the underlying Cache instead of implementing its own version.

@SachinAgarwal1337
Copy link
Owner Author

@mallardduck Makes Sense. Will try to add caching.

@juliomotol
Copy link

juliomotol commented Nov 28, 2019

Specific exceptions for failed request would be nice! Could look something like below:

try{
    $google_places_response = GooglePlaces::nearbySearch($location, $radius, $params);
}catch(OverQueryLimitException $e){
    // handle OVER_QUERY_LIMIT response error
}catch(RequestDeniedException $e){
    // handle REQUEST_DENIED response error
}catch(InvalidRequestException $e){
    // handle INVALID_REQUEST  response error
}catch(UnkownErrorException $e){
    // handle UNKNOWN_ERROR  response error
}

I felt good and took on the task of implementing this. see pull request.

My first contribution on an open source project. Don't show mercy, I can take it :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants