Mapstraction Google Geocode call returns error code 610 - google-geocoder

I have this js code where I am using the Mapstraction library to show GMap and use it's geocoder service via mapstraction as well.
I have recently started getting error 610 whenever I try to issue the geocode service call. The http code is 200 ok however the json returned is as follows:
_xdc_._8gxa9q7ci && _xdc_._8gxa9q7ci( {
"Status": {
"code": 610,
"request": "geocode"
}
})
Chromium's inspector shows the request string as follows:
output:json
oe:utf-8
q:nehru place, , delhi,110048, in
mapclient:jsapi
hl:en
callback:_xdc_._8gxa9q7ci
The issue remains even with a newly generated api key! The map loads just fine with the new key as well as the old key!
So if anyone has run into a similar issue with mapstraction then do let me know the workarounds if any.
Another thing that I have noticed is that my old key is 86 characters long whereas my new key is only 39 characters long. Any insights in this direction would be greatly appreciated. I have spent an entire day trying to get it to work again.
Update: I have noticed that with a key length of 86 characters, the request string has key: MYKEY param as well. Whereas with the 39 character long key, it's not there!

Mapstraction seems to require a 86 character api key to work properly with GMap API v2.
The 36 character API key is for v3 I guess.
If I goto the API console, the 86 character keys generated for my domains isn't shown there. However, the link to generate the 86 character api key is a bit hard to get.
Once generated, my calls to GMap's Geocoder via Mapstraction are working fine now.
Here's the link to generate the v2 API key
http://code.google.com/apis/maps/signup.html
Remember to scroll to the bottom of the page to fill in the correct url.
As for Mapstraction, I think the latest version should be able to use the new 36 character API key!

Related

how can I get ALL records from route53?

how can I get ALL records from route53?
referring code snippet here, which seemed to work for someone, however not clear to me: https://github.com/aws/aws-sdk-ruby/issues/620
Trying to get all (I have about ~7000 records) via resource record sets but can't seem to get the pagination to work with list_resource_record_sets. Here's what I have:
route53 = Aws::Route53::Client.new
response = route53.list_resource_record_sets({
start_record_name: fqdn(name),
start_record_type: type,
max_items: 100, # fyi - aws api maximum is 100 so we'll need to page
})
response.last_page?
response = response.next_page until response.last_page?
I verified I'm hooked into right region, I see the record I'm trying to get (so I can delete later) in aws console, but can't seem to get it through the api. I used this: https://github.com/aws/aws-sdk-ruby/issues/620 as a starting point.
Any ideas on what I'm doing wrong? Or is there an easier way, perhaps another method in the api I'm not finding, for me to get just the record I need given the hosted_zone_id, type and name?
The issue you linked is for the Ruby AWS SDK v2, but the latest is v3. It also looks like things may have changed around a bit since 2014, as I'm not seeing the #next_page or #last_page? methods in the v2 API or the v3 API.
Consider using the #next_record_name and #next_record_type from the response when #is_truncated is true. That's more consistent with how other paginations work in the Ruby AWS SDK, such as with DynamoDB scans for example.
Something like the following should work (though I don't have an AWS account with records to test it out):
route53 = Aws::Route53::Client.new
hosted_zone = ? # Required field according to the API docs
next_name = fqdn(name)
next_type = type
loop do
response = route53.list_resource_record_sets(
hosted_zone_id: hosted_zone,
start_record_name: next_name,
start_record_type: next_type,
max_items: 100, # fyi - aws api maximum is 100 so we'll need to page
)
records = response.resource_record_sets
# Break here if you find the record you want
# Also break if we've run out of pages
break unless response.is_truncated
next_name = response.next_record_name
next_type = response.next_record_type
end

Google Service Account "Invalid JWT Signature"

I am attempting to write some code in webDNA to connect to the google drive api. Using the service account seems to be the best solution for the given problem. From what I have read the process is... create the JWT, send the JWT to google to get a token response, then send the taken response to call api methods.I believe my issue is with the private key.
I build and encrypt the header:
[text]header={"alg":"RS256","typ":"JWT"}[/text]
[text]header=[encrypt method=Base64][header][/encrypt][/text]
[text]header=[db_base64URL varName=header][/text][!]custom function to deal with special characters[/!]
Next build and encrypt the claim(added white space for readability):
[text]claim={
"iss":"xxx",
"scope":"https://www.googleapis.com/auth/drive",
"aud":"https://www.googleapis.com/oauth2/v4/token",
"exp":[Math][cTime]+3600[/Math],
"iat":[cTime]
}[/text]
[text]claim=[encrypt method=Base64][claim][/encrypt][/text]
[text]claim=[db_base64URL varName=claim][/text]
Those sections seem to be correct, now to build the signature:
[text]p_key=-----BEGIN PRIVATE KEY-----xxxx-----END PRIVATE KEY-----\n[/text]
[text]sig=[encrypt method=SHA256][header].[claim].[p_key][/encrypt][/text]
[text]sig=[encrypt method=Base64][sig][/encrypt][/text]
[text]sig=[db_base64URL varName=sig][/text]
I have tried moving the [p_key] around, outside the sha256 encryption and inside, with and without the '.', I don't get an error till I try to send it to google using [TCPConnect] and [TCPSend] here:
[text show=T]response=[!]
[/!][TCPconnect host=accounts.google.com&SSL=T&port=443][!]
[/!][TCPsend skipheader=T]POST /o/oauth2/token HTTP/1.1[crlf][!]
[/!]Host: accounts.google.com[crlf][!]
[/!]Content-Type: application/x-www-form-urlencoded[crlf][!]
[/!]Content-Length: [countchars][sendData][/countChars][crlf][!]
[/!]Connection: close[crlf][!]
[/!][crlf][!]
[/!][sendData][crlf][!]
[/!][/TCPsend][!]
[/!][/TCPconnect][/text]
When the response is shown it is displayed as:
{
"error": "invalid_grant",
"error_description": "Invalid JWT Signature."
}
This error message is less that helpful, from what I have read it could mean one(or more) of any number of things and google's documentation on this is not exactly helpful. If anyone has any experience using the google apis through webDNA I would appreciate any help you could give!

Trouble fetching JSONArray key from server

1) I have an Object (JB8XGctiZw) that has to keys: "patternName", and "tempoIntensities". When I run the following code, It will fetch the correct values of both keys.
ParseObject parseObject=ParseObject.createWithoutData("AudioPattern", "JB8XGctiZw");
parseObject=parseObject.fetch();
parseObject.pin();
Log.d("pattern",parseObject.getJSONArray("tempoIntensities").toString());
Log.d("pattern",parseObject.getString("patternName"));
2) From the web interface I change value contents for BOTH keys.
3) Run again the above code and it will successfully bring me the new value for "patterName", but "tempoIntensities", the JSONArray, will not be updated.
The only way to get the JSONArray updated is to clear local storage.
Is this a bug? Is this behavior normal?
Regards
It seems to be an issue with using ParseObject.getJSONArray and ParseObject.getJSONObject. For the moment I fixed this using ParseObject.get() and then casting it.
The version of Parse this applies to is 1.8.2,
And there is an assigned issue here:
https://developers.facebook.com/bugs/846833412048862/
You should be logged in to facebook to see this bug

Bing translator HTTP API throws bad request error, how to solve this?

Whenever I call Bing Translation API [HTTP] to translate some text, first time it works fine, and second time onwards it gives me 'bad request' [status code 400] error. If I wait for 10 or so minutes and then try again, then first request is successful, but second one onwards same story. I have a free account [2million chars translation] with Bing Translation APIs, are there any other limitations calling this API?
Thanks, Madhu
Answer:
hi, i missed to subscribing to Microsoft Translator DATA set subscription. Once i get the same, then things have solved. i.e; once i have signed up for https://datamarket.azure.com/dataset/bing/microsofttranslator then things are working.
i was generating the access_token correctly, so that is not an issue.
thanks, madhu
i missed to subscribing to Microsoft Translator DATA set subscription. Once i get the same, then things have solved. i.e; once i have signed up for https://datamarket.azure.com/dataset/bing/microsofttranslator then things are working.
i was
thanks, madhu
As a note to anyone else having problems, I figured out that the service only allows the token to be used once when using the free subscription. You have to have a paid subscription to call the Translate service more than once with each token. This limitation is, of course, undocumented.
I don't know if you can simply keep getting new tokens -- I suspect not.
And regardless of subscription, the tokens do expire every 10 minutes, so ensure you track when you receive a token and get a new one if needed, e.g. (not thread-safe):
private string _headerValue;
private DateTime _headerValueCreated = DateTime.MinValue;
public string headerValue {
get {
if(_headerValueCreated < DateTime.Now.AddMinutes(-9)) {
var admAuth = new AdmAuthentication("myclientid", "mysecret");
_headerValue = "Bearer " + admAuth.GetAccessToken();
_headerValueCreated = DateTime.Now;
}
return _headerValue;
}
}

Google Spreadsheet API - returns remote 500 error

Has anyone battled 500 errors with the Google spreadsheet API for google domains?
I have copied the code in this post (2-legged OAuth): http://code.google.com/p/google-gdata/source/browse/trunk/clients/cs/samples/OAuth/Program.cs, substituted in my domain;s API id and secret and my own credentials, and it works.
So it appears my domain setup is fine (at least for the contacts/calendar apis).
However swapping the code out for a new Spreadsheet service / query instead, it reverts to type: remote server returned an internal server error (500).
var ssq = new SpreadsheetQuery();
ssq.Uri = new OAuthUri("https://spreadsheets.google.com/feeds/spreadsheets/private/full", "me", "mydomain.com");
ssq.OAuthRequestorId = "me#mydomain.com"; // can do this instead of using OAuthUri for queries
var feed = ssservice.Query(ssq); //boom 500
Console.WriteLine("ss:" + feed.Entries.Count);
I are befuddled
I had to make sure to use the "correct" class:
not
//using SpreadsheetQuery = Google.GData.Spreadsheets.SpreadsheetQuery;
but
using SpreadsheetQuery = Google.GData.Documents.SpreadsheetQuery;
stinky-malinky
Seems you need the gdocs api to query for spreadsheets, but the spreadsheet api to query inside of a spreadsheet but nowhere on the internet until now will you find this undeniably important tit-bit. Google sucks hard on that one.

Resources