سؤال

I am trying to use google geocoding. If i just type

https://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&sensor=true

it gives me right output. I am trying to use this with a amazon proxy server and it gives

{ "error_message" : "The 'sensor' parameter specified in the request must be set to either 'true' or 'false'.", "results" : [], "status" : "REQUEST_DENIED" }

This the code

http://ec2-00-000-000-000.compute-1.amazonaws.com/OsProxy/getpage.aspx?p=https://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&sensor=true

Can someone help me?

Thanks Rashmi

هل كانت مفيدة؟

المحلول

You need to URL-encode your parameters. Consider the URL you're using:

http://ec2-00-000-000-000.compute-1.amazonaws.com/OsProxy/getpage.aspx?p=https://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&sensor=true

This is parsed as:

http://ec2-00-000-000-000.compute-1.amazonaws.com/OsProxy/getpage.aspx?
    p=https://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&
    sensor=true

That is, you're passing the sensor parameter to amazonws.com, not to googleapis.com.

Since the only parameter to amazonws.com should be the full URL, encode that URL so it reaches amazonws.com as a single parameter to be passed through to googleapis.com:

http://ec2-00-000-000-000.compute-1.amazonaws.com/OsProxy/getpage.aspx?p=https%3A%2F%2Fmaps.googleapis.com%2Fmaps%2Fapi%2Fgeocode%2Fjson%3Faddress%3D1600%2BAmphitheatre%2BParkway%2C%2BMountain%2BView%2C%2BCA%26sensor%3Dtrue
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top