Google Global Address List for Domain limited to 250 results [rehash] - google-api

Reposting due to lack of answers
I'm trying to query Google Global Address List for a specific domain, being led by this answer here (Specifically the answer by Jay Lee).
It's all well and good and works perfectly in Google's OAuth Playground, however it seems to be limited to 250 users. Given that this feature seems completely undocumented, and that I can't tell by looking at their github repo (specifically this file), does anyone know how to query for the next 250 users or how to set the number of results?
Thank you!

My last answer was converted into a comment, but I now have a complete answer to this question.
EDIT: I repeatedly mention JSON but you don't need to parse this in JSON to get the syncToken. Google will provide you the syncToken regardless.
The Google GAL API seems to operate in a similar manner to the Google Calendar or YouTube API's "nextPageToken" parameter, which allows you to query the next page of results as long as you have a token.
The Google GAL uses the "syncToken" parameter as a replacement. Much like the other Google API's, if you append this syncToken to the end of your URL, you will get the next page of results. Note that I was unable to get the startIndex parameter to work (which allows you to begin at a specific item in the JSON), so if you are trying to get a specific result through the query you will most likely have to parse the entire JSON file. Inside the parsed JSON, there should be a key called "gal$syncToken." You can find it in the json right before the "entry" key/array which is where all of the global domain contacts are listed.
Here is an example of what it would look like:
"gal$syncToken": {
"$t": "0_1001_17011_AAN3FFNH2AEJ3SFBKZDRS36AHRXHND47YACXLGFJF5QBXCSQLUK57EX3LC765CU5IWG6ZXWHPS5WKHSDFJ26LRI5FRIVIQ3Z532PWKG3ZG45JW3RVCDZMWK5LLLHZSCBTJH5U6Q4LZRG4PKWQE42AOIPC4VJCZQIP5MBJHNUBZZJNLKISKETTQ6DNTRAPTI"
},
Your syncToken will look different. To get the next page of results, Google actually provides a link that already has the syncToken pre-appended:
{
"rel": "next",
"type": "application/atom+xml",
"href": "https://www.google.com/m8/feeds/gal/example.com/full?sync-token=0_1001_17011_AAN3FFNH2AEJ3SFBKZDRS36AYRXHND47YACXLGFJF5QBXCSQLUK57EX3LC765CU5IWG6ZXWHPS5WKHSDFJ26LRI5FRIVIQ3Z562PWKG3ZG45JW3RVCDZMWK5LLLH6SCBTJH5U6Q4LZRG4PKWQE42AOIPC4VJCZQIP5MBJHNUBZZJNLKBSKETTQ6DNTRAPTI"
},
However, this will only give you the next 250 results. If you want more on each page, you can append the max-results parameter to this and have Google spit it back out in JSON format.
https://www.google.com/m8/feeds/gal/example.com/full?sync-token=INSERT_SYNCTOKEN_HERE&alt=json&max-results=10000
Hope this helped anyone seeing this. The Google GAL seems to be largely undocumented for the most part and I was unable to find an answer to this question anywhere else on the internet. If anyone from Google can confirm that this is the best method for accomplishing this that would be great!

Related

Google Places API setFields AND getDetails

The google places api docs clearly state: "IMPORTANT: To avoid paying for data that you don't need, be sure to use Autocomplete.setFields() to specify only the place data that you will use." But then when I'm calling the getDetails() method (see in generic-y form below), I'm specifying my fields, which is what setFields() sets.
I THINK I'm basically setting them via the getDetails() method, but given the caution exercised in the docs, I also don't want to surprise anyone with extra costs besides what we need. I've tried to find a clear answer in the docs, but I haven't found one. I'm hoping someone here knows from experience or has better luck with the docs. Thanks!
const placesService = new google.maps.places.PlacesService(myField);
placesService.getDetails(
{
fields: ['address_components'],
placeId: result.place_id,
sessionToken: token,
},
details => this.updateMethod(details.address_components),
);
Autocomplete.setFields is used when implementing Places Autocomplete Widget which will constrain the succeeding Places Details request to specific fields only when a user selects a place from the suggestions. Check out the example here.
However, as for your given sample code, I can see that you are directly using Places Service to get the details of a place given a Place ID and not from the Autocomplete Widget suggestions. With this, you can just set the fields in the request parameter of the getDetails(request, callback) method which is what you have correctly done in your code. See this example.
Hope this helps!

Where do I find the workflow id of an automation in Mailchimp?

I would like to use Mailchimp Api 3.0 to add a subscriber to an automation workflow, but I can't find where the workflow_id or workflow_email_id are located... this is from the documentation:
POST /automations/{workflow_id}/emails/{workflow_email_id}/queue Add a subscriber to a workflow email
http://developer.mailchimp.com/documentation/mailchimp/reference/automations/emails/queue/
Can anyone tell me to find it? It's probably somewhere really obvious. I mean the list_id is well covered, but I can't find any info about this.
I found this confusing as well. Here is how I got the answer:
Send a GET request to https://us9.api.mailchimp.com/3.0/automations to find the workflow_id
With the workflow_id, send a GET request to https://us9.api.mailchimp.com/3.0/automations/<workflow_id>/emails to find the workflow_email_id. The workflow_email_id will be the "id" in the array that's returned.
From there you can make POST requests to https://us9.api.mailchimp.com/3.0/automations/<workflow_id>/emails/<workflow_email_id>/queue
Keep in mind you might need to subscribe an email address to a list first for the post request to work. To subscribe you can use: https://us9.api.mailchimp.com/3.0/lists/<list_id> with your data:
{
"members": [{
"email_address" : "emailaddress#whatever.com",
"status": "subscribed"
}]
}
The answer is found in the official mailchimp knowledge base: It explains that you simply go into the workflow and read the id from the URL.
Other ways to get id information about anything:
Using the API endpoint, detailed here: http://developer.mailchimp.com/documentation/mailchimp/reference/automations/
You'll see that the Response body parameters return everything about the automations, including the id.
Probably the easier way: use the developer playground https://us1.api.mailchimp.com/playground/?_ga=1.218336095.774374564.1480036371
So, once you set up your lists and automations, go into the playground, and you'll find all the ids you'll need for everything.

How to do Partial Response with Google URL Shortener API

Looking at the documentation on this API there is a page on performance to cut back the number of keys in the JSON dictionary returned. URL Shortener Performance Tips
Of the three dictionary keys returned in the insert request of this API, I am only interested in the shortened URL. The id key. Looking at the above documentation I would have expected this to work:
The POST request https://www.googleapis.com/urlshortener/v1/url?fields=id?key=YOUR-API-KEY
But with the fields=id added the request comes back invalid.
How do you set only a partial response for this API to only return the id key?
Turns out the comment from abraham steered me in the right direction on this problem. I was able to find the Try it tool option without OAuth and it worked also to my surprise. Looking at the request it generated I found that it was a syntax error on my part looking at the url given in my original question. It should be:
?fields=id&
not
?fields=id?

How can I get ESPN Developer to return more golfers?

I just created an account with ESPN Developer, and I'm trying to get a list of all the Professional Golfers. I made the following request:
http://api.espn.com/v1/sports/golf/athletes?&apikey=[mykey]
Unfortunately, the browser only shows a handful of names (which are in alphabetical order). How can I get the API request to return all the golfers?
According to my research, you should be seeing all of the Golfers that they have.
If you use http://api.espn.com/v1/sports/golf?apikey=KEY, you will get a list of "all organizing bodies" in the sport. You can (if you have the patience) go through that list, and check to see if they are listed in the data returned from your (correct) API URI, along with the members of each section.
You can also use http://api.espn.com/v1/sports/golf/pga/athletes?apikey=KEY to get a list of athletes in that organization. Be sure to replace "pga" if you are looking for something else.
I just now created a Developer account there and requested a key to assist you with your question, so I could be wrong. If I am I will certainly come back to better answer your question.
I am reading this post http://www.javacodegeeks.com/2013/06/parsing-espn-api-using-java-and-google-gson.html
The NBA request http://api.espn.com/v1//sports/basketball/nba/athletes?apikey=KEY returns only 50 athletes, you have to use the offset parameter to get more
http://api.espn.com/v1//sports/basketball/nba/athletes?apikey=KEY&offset=51
So in your case
http://api.espn.com/v1/sports/golf/athletes?&apikey=KEY&offset=51
I am still reading the post but now I see I can return more players and the first request only got to players last name ending with B so geeze to get all athletes the JSON response would be huge!
I can't find this on the ESPN docs, so I don't know how developers are supposed to know this, there may be a better way but at least now I know how to get all the players.

Sorting places by distance - Android

I am using Google places API for writing my android app. I want to get a list of places close to current location of the device based on prominence(i.e I do not want to pass "keyword" or "type" or "name" parameter in my URL). Is there a way to do this?
According to the following link, you have to pass keyword, name or type parameter in the URL.
https://developers.google.com/places/training/additional-places-features
I searched google and quite many threads on stackoverflow, but could not find much useful help in using rankby=distance parameter. I would appreciate it if you could share your experiences on sorting places by distance using google places API.
Thank you for your help.
NOTE:
The following URL fails:
https://maps.googleapis.com/maps/api/place/search/json?location=37.787930,-122.4074990&rankby=distance&sensor=false&key=
Keyword, Type and Name are all optional parameters. You only need to pass your API Key, Location and sensor. See the following link for details:
https://developers.google.com/places/documentation/search

Resources