Partial postcode returns the correct result on Bing maps while the complete postcode doesn't - bing-maps

Why is it when I request some postcodes from Bing maps I get an incorrect coordinates
http://dev.virtualearth.net/REST/v1/Locations?postalCode=IM1+1LD&countryRegion=GB&o=xml&key=MY_BING_KEY
While when I request it using this I get the correct ones
http://dev.virtualearth.net/REST/v1/Locations?postalCode=IM1&1LD&countryRegion=GB&o=xml&key=MY_BING_KEY
i.e. when I send IM1+1LD as a postalcode incorrect results are returned, while sending IM1&1LD returns the correct results in the response.

The + indicates your are escaping rather than encoding your query. The plus should be %20 instead. Also, in the UK postal codes are a special case. I recommend searching for them using a query search instead like this: http://dev.virtualearth.net/REST/v1/Locations?q=IM1%201LD&o=xml&key=YOUR_KEY
You can find additional tips on use the REST services here: https://blogs.bing.com/maps/2013/02/14/bing-maps-rest-service-tips-tricks

Related

How can I use the Bing Maps API to check if a postcode exists?

I need to use the Bing Maps API to check if a UK postcode (Not sure how different it is for other countries) is valid.
It seems that I can put any nonsense into the field for postcode and I still get a response.
E.G. http://dev.virtualearth.net/REST/v1/Locations/GB/aregsfdgsdfgsdfgdsf?key=BINGMAPSKEYHERE
Gives a result that has a lat and long of 53.9438323974609, -2.55055809020996 in the "point" field, despite that clearly not being a valid postcode.
Is there a way that I can simply test the validity of a postcode?
If you look at the response object for your request you will see a matchCode value. This indicates if the match it is good or not. In this case it says "UpHierarchy" which indicates that it didn't find the exact result so it when up the address hierarchy until it found a result. The result being returned is for the United Kingdom. Additionally, the results also have an entityType value which tells you the type location that was found. In this case it says CountryRegion. You want an entityType value of "PostalCode". By checking these two values you can determine if the returned result is a postal code or not. More details on the geocode response object is documented here: https://msdn.microsoft.com/en-us/library/ff701725.aspx
One thing I would highlight is that the URL format you are using is a bit of a legacy one and isn't as accurate as passing in a single string query (i.e. &q=YOURQUERY). This is highlighted in the best practices docs. If you are using .NET, I hiehgly recommend using the Bing Maps .NET REST toolkit. It makes things really easy and implements best practices for you.

Invalid signature returned when previewing 7digital track

I am attempting to preview a track via the 7digital api. I have utilised the reference app to test the endpoint here:-
http://7digital.github.io/oauth-reference-page/
I have specified what I consider to be the correct format query, as in:-
http://previews.7digital.com/clip/8514023?oauth_consumer_key=MY_KEY&country=gb&oauth_nonce=221946762&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1456932878&oauth_version=1.0&oauth_signature=c5GBrJvxPIf2Kci24pq1qD31U%2Bs%3D
and yet, regardless of what parameters I enter I always get an invalid signature as a response. I have also incorporated this into my javascript code using the same oauth signature library as the reference page and yet still get the same invalid signature returned.
Could someone please shed some light on what I may be doing incorrectly?
Thanks.
I was able to sign it using:
url = http://previews.7digital.com/clip/8514023
valid consumer key & consumer secret
field 'country' = 'GB'
Your query strings parameters look a bit out of order. For OAuth the base string, used to sign, is meant to be in alphabetical order, so country would be first in this case. Once generated it doesn't matter the order in the final request, but the above tool applies them back in the same order (so country is first).
Can you make sure there aren't any spaces around your key/secret? It doesn't appear to strip white space.
If you have more specific problems it may be best to get in touch with 7digital directly - https://groups.google.com/forum/#!forum/7digital-api

Unable to get coordinates from bing map REST api

We have a list of address, And trying to get coordinates of them using server side script.
Due to limitation of google map api(2500 query per 24 hour), We move to bing map REST api.
But when we are calling API its not giving the coordinates, While google map api returning the correct coordinates.
Please tell me what i am doing wrong?
Here is the sample call
http://dev.virtualearth.net/REST/v1/Locations?query=A+Beka+Acadamdy,2303+Maravilla,Lompoc,CA,93436,&incl=queryParse&key=MY_API_KEY
if I replace everything with %20 in address then still its not returning data
http://dev.virtualearth.net/REST/v1/Locations?query=A%20Beka%20Acadamdy%202303%20Maravilla%20Lompoc%20CA%2093436&incl=queryParse&key=MY_API_KEY
Another URL is
http://dev.virtualearth.net/REST/v1/Locations?query=103+Black+Men+of+the+Bay+Area+Community,3403+Malcolm+Avenue,Oakland,CA,94607-1407,&incl=queryParse&key=MY_API_KEY
We also tried with this
https://msdn.microsoft.com/en-us/library/ff817004.aspx#sectionToggle6
But sometimes we don't know the country, That's why its not working correctly.
A couple of things to change. First, drop the name of the location, you only need the street address.
So geocoding "2303 Maravilla, Lompoc, CA, 93436" will work.
Secondly, it looks like you are escaping the query value rather than encoding it. Escaping isn't as good as encoding and will result in some queries failing all together. For example if a query had "first & Main" in it, escaping it would not escape the ampersand which would make everything after it a new URL parameter which would likely either cause an error or mean your query is just for "first". By encoding it the ampersand would be changed to %26. This is documented in the best practices here: https://msdn.microsoft.com/en-us/library/dn894107.aspx
By encoding your query parameter your address will look like this:
"2303%20Maravilla,%20Lompoc,%20CA,%2093436"

Facebook Graph API Non English Search Queries

I've been trying to use facebook graph api public search.
It works just fine for english search queries, for example,
http://graph.facebook.com/search?q=watermelon%20&type=post
On the other hand, while setting a non english search result, I'm also receiving only english results, but non of the results in a result in the language of the search query.
For example,
http://graph.facebook.com/search?q=ביבי&type=post
Does not return any relevant result (the search query is "ביבי" , a word in Hebrew. None of the returned results are in Hebrew).
What could I do to fix it ?
Any suggestion will be helpful.
Thanks in advance.
To receive response in a locale which is different from your computer default locale, you should specify it with the request. Right now there are 2 ways to do that:
use &locale=he_IL in the URL (list of Facebook locales), e.g.
https://graph.facebook.com/search?q=YOUR_QUERY&type=post&fields=message&locale=he_IL
use Accept-Language header with your request, e.g.
'Accept-Language': 'he_IL,he,iw;q=0.9'
Recently, the first approach had a bug (now it works well), so I would use both of them (the first one will have more priority then another).
Note: Search across the specified locale will return posts available in this locale.

Calculating the driving distance between two points using PHP only (Bing maps)

I'd like to work out the distance between two points. No map. No javascript. Just the distance.
I understand Google maps prohibits this and it's against their terms of service. But Bing Maps doesn't have this restriction.
I want to give the points in a general format, i.e "Cambridge" "Church Street, Newcastle"
How would I go about doing it? As basic as possible. It's for a mobile device.
1.) Sign up for a Bing Maps key at http://www.bingmapsportal.com. A key is a alphanumeric string of around 64 characters in length, something like: AtGYpcoIpC5zy0P2k4Bc4839b-=fLgbbnsp72T3ZrM0z7gAaMcjXlZPsKXghW
2.) Then, make a request to the Bing Maps Routes API (http://msdn.microsoft.com/en-us/library/ff701717.aspx) to generate a route between up to 25 waypoints. For the example given, substitute your Bing Maps key into the following URL:
http://dev.virtualearth.net/REST/v1/Routes?wp.1=Cambridge, UK&wp.2=Church St, Newcastle-under-Lyme, UK&key=ENTERYOURBINGMAPSKEYHERE
3.) You'll get a JSON response containing details of the route, turn-by-turn directions etc. as described at: http://msdn.microsoft.com/en-us/library/ff701718.aspx. The total driving distance is given quite near the bottom of the response, called "travelDistance" (in this case,218.703). You can also choose what units this value is returned in by specifying the appropriate distanceUnit parameter when you first request the route.
Is very simple:
http://dev.virtualearth.net/REST/V1/Routes/Walking?wp.0=11025%20NE%208th%20St%20Bellevue%20WA&wp.1=700%20Bellevue%20Way%20NE%20Bellevue WA&key=BingMapsKey
Ref : MSDN