Closed anthonytison closed 11 years ago
Can you elaborate a bit please?
Yes of course. I have a business account in order to increase the maximum of requests for getting directions, geocoding...
So in order to use my account, i must include my client id into the google apis url (ex: http://maps.googleapis.com/maps/api/directions/json?client=[clientID]) and also calculate the signature with a crypto key provided by Google.
You can have more information here : https://developers.google.com/maps/documentation/business/clientside/
It could be great to set 2 more parameters (clientID & cryptoKey) in config.yml and have them directly in all api calls.
I hope my explanation will help you to understand my need.
Thanks
Okay, I think I got it :) IMO, your link is wrong as it is about client side (JS), this one (https://developers.google.com/maps/documentation/business/webservices) is better. Is it what you want?
Indeed the link was wrong ;) and yes it's exactly what i need. I hope you will be able to improve your bundle with this feature.
What is the service you would like to get first? Geocoder or an other? I ask this question because the Geocoder does not use the same implementation than the others.
The directions service will be great. Thx
@anthonytison I have push a proposal in the referenced PR. Can you try it with you own account?
@egeloen I definitely miss something.
I've created a new BusinessAccount with my account datas but how bind the directions service with my business account. Is it automatic or do i have to use a setter ?
So far the directions service url gets no clientID and no secret key.
@anthonytison My PR is not finished (missing some tests & all the doc...). To test it you need to set a business account on the service & then everything is done automatically.
$directions->setBusinessAccount(new BusinessAccount('client_id', 'secret'));
$reponse = $directions->route('Washington', 'Mexico');
Basically, I have not tested it as I have no business account... So, IMO, there is probably something wrong in AbstractService::signUrl
. I let you give me some feedbacks :) I have based my implementation according to https://developers.google.com/maps/documentation/business/webservices/auth & http://gmaps-samples.googlecode.com/svn/trunk/urlsigning/UrlSigner.php-source
@egeloen I've tested with my business account and i got this error :
Argument 1 passed to Ivory\GoogleMap\Services\Directions\Directions::buildDirectionsResponse() must be an instance of stdClass, null given, called in /vendor/egeloen/google-map/src/Ivory/GoogleMap/Services/Directions/Directions.php on line 70 and defined in /vendor/egeloen/google-map/src/Ivory/GoogleMap/Services/Directions/Directions.php line 222
For the url signing functions, i used the same script on the master branch of my project and it works very well so i have no doubt it will work in this case too :)
Okay, if you got this error means the http adapter does not return a valid json response (json_decode returns null when it fails). Can you check what is the value of $response
here: https://github.com/egeloen/ivory-google-map/blob/0f8576b83da1867c529935a7effe631a8d7c3767/src/Ivory/GoogleMap/Services/Directions/Directions.php#L69
And at the same time, check if the generated url seems valid.
@egeloen A note for me, add a check if json_decode fails in all services.
First of all, i had twice the prefix gme- as a client ID value and signature was wrong. Now the url is fine but the signature is not valid for my client ID.
This is what i get :
'Unable to authenticate the request. Provided \'signature\' is not valid for the provided client ID. Learn more: https://developers.google.com/maps/documentation/business/webservices/auth'
When google provide you the client ID, is it prefixed by gme-
? By default, you should provide your client_id without the gme-
prefix as it is prepended automatically according to the spec.
Yes of course this is why i add a doublon in the url on my first test. Now the url has just one gme- prefix.
This is what it looks like :
So, does it work?
Nop apparently the signature is not valid.
'Unable to authenticate the request. Provided \'signature\' is not valid for the provided client ID. Learn more: https://developers.google.com/maps/documentation/business/webservices/auth'
I just push a fix. Can you retry plz?
It works now :)
Let me know when you will merge this new feature on the master branch and i will make an update via composer.
Thank you so much.
:+1:
@anthonytison Everything is merged in master. I just integrates the change in the bundle. See #90 & https://github.com/egeloen/IvoryGoogleMapBundle/blob/master/Resources/doc/usage/services/business_account.md
Hi,
Could you please add the possibility to set a client id ?
I need to bind my business account with your bundle.
Thank you