The public subscriber lists pages not matching batch size and total counts - youtube-data-api

I am trying to get a list of my public subscribers. When I execute the request below I get weird and inconsistent results. When I ask for a max result size of 50 I get two pages back, one with 27 and another with 9. Also when I look at my web page subscribers it says I only have 24 public subscribers. I have 95 total subscribers.
Why is it paging in buckets less than my max page size?
Why are the reported numbers so far off?
https://www.googleapis.com/youtube/v3/subscriptions?part=subscriberSnippet&mySubscribers=true&key=[MY_API_KEY]

According to the official docs, for to call the Subscriptions.list API endpoint with parameter mySubscribers=true you have to pass on to the endpoint proper authorization credentials:
mySubscribers (boolean)
This parameter can only be used in a properly authorized request. Set this parameter's value to true to retrieve a feed of the subscribers of the authenticated user in no particular order.
Therefore, passing on only an application key, via the parameter key, is not sufficient. If passing on proper authorization credentials (i.e. a valid access token), then the key parameter is superfluous.

Related

Using slack API to get conversation lists

I am trying to invoke following slack API to fetch private and public channels.
https://api.slack.com/methods/conversations.list
By default as per slack documentation 200 channels are returned at a time when limit is given 1000.
I am passing types= “private_channel,public_channel“ to get the private as well as public channels.
If I pass the types = public_channel with limit 1000 or 9999,
162 channels are returned
If I pass the types= private_channel,public_channel with limit
1000 or 9999,
105 channels are returned
Can anybody please answer same.
With the way pagination works in that API, it's possible to get fewer than the number of results you're asking for, even if there are more results in the total collection to return. You'll need to check if there are additional pages of results and crawl through all of them to build the complete set.
This is because of the way data is retrieved in the back end -- it includes archived data, data of other types -- all the filtering that happens for your result happens after the data is fetched, making additional API calls required to get the next window of data to be filtered and then presented to you.
Here's the relevant documentation:
It's possible to receive fewer results than your specified limit, even when there are additional results to retrieve. Avoid the temptation to check the size of results against the limit to conclude the results have been completely returned. Instead, check the next_cursor value in the response_metadata object to make sure that it's empty, null, or non-existent.

Pass data between 2 handler-functions without form-, URL-, or query-parameters in Golang?

I have the following example: (a "quiz" with 3 phases; only after the 3rd phase should all combined points get stored in the database)
GET-method (.com/play/phase1), consists of a form. User got 5 points. Total: 5
GET-method (.com/play/phase2), consists of a form. User got 3 points. Total: 8 (5+3)
GET-method (.com/play/phase3), consists of a form. User got 13 points. Total: 21 (5+3+13)
Points get stored in a database
How do I transfer the points from one handler-function to another? I understand retrieving values from forms, URL, or query. Should I perhaps pass it through as a query-parameter? (.com/play/phase2?points=5)
How do I do this in Go?
You'll have two choices of passing the data to your different handlers between subsequent requests:
Make the Go app store the values. Either in memory or a database. Here you'll have to figure out how to associate a given user to the stored values. This could be done via a browser session cookie with randomly generated ID. You could also pass this random session ID via querystring parameter if you find that easier. The gist is to have a sticky value associated with all requests of a user so you can use that as a key when looking up the corresponding data.
You can give the result back to the browser in the HTTP response and let the browser then pass it on in the next request as you alluded. This can be done in many ways like querystring, URL, POST body or cookie. The improtant thing to keep in mind here is that the user can forge/manipulate this data easily. The only way to prevent this is by signing or encrypting the data so the backend can be sure that it was not modified by the client.
You can store the points in an in-memory cache map like https://github.com/dgraph-io/ristretto with a key like username+phase1 as a key and their points as the value in the map. You can also specify how long the value needs to be in cache with the https://godoc.org/github.com/dgraph-io/ristretto#Cache.SetWithTTL method in case your quiz has an expiration time.

What is the default value of maxResults in contacts API call?

I've read the official document of Google Contacts API version 3.0.
(https://developers.google.com/contacts/v3/)
On the part of 'Retrieving all contacts' there is a note saying below:
The feed may not contain all of the user's contacts, because there's a default limit on the number of results returned. For more information, see the max-results query parameter in Retrieving contacts using query parameters.
I wonder that 'default limit' because I would like to refer to Google's standard for developing.
Is there anyone who knows the number of default limit?
The default max depends upon the API and the method itself. Some of the Youtube methods only return 50 for a max others return 500.
Unfortunately the Google contacts API is a very old API and not well documented. If you dont send a max-results with your request then you will get the default.
You can also send something really big like 100000 if it refuses it it should return an error stating its max.

MailChimp API not displaying all the newsletters

I am using mailchimp to display all the newsletters in my webpage.
Am using this API call to get all newsletters, https://usX.api.mailchimp.com/3.0/campaigns
But am only getting 10 campaigns, but there are many more campaigns in the mailchimp account.
Is there anything wrong here?
How can I get all the newsletters or all campaign ids?
According to the official documentation of the /campaigns endpoint here, there is a count parameter that indicates the number of campaign records you want to return. The default value of the count parameter is 10. You're not passing any parameters to the /campaigns endpoint, so the default value of the count parameter (10) is used and that's why you only get 10 campaigns.
You can get all campaigns by making two API calls to the /campaigns endpoint. Make the first API call with count parameter set to 1. You will get only one campaign, but you will also get total_items in the response body. The value of total_items shows the total number of campaigns you currently have in your MailChimp account. The second API call should have count parameter set to the value of total_items obtained from the response of the first API call. You will get all campaigns in the response body of the second API call.

Exchange Web Services EWS, search mails in in-place eDiscovery & hold

I want to download mails that matches the in-place eDiscovery. I do a GetDiscoverySearchConfiguration(), then I execute SearchMailboxes() for each mailbox that GetDiscoverySearchConfiguration() returns. SearchMailboxes() returns SearchPreviewItems() where I can get the real EmailMessage Id but this does not have the email body, so I have to do another retrieve using FindItems() to get the EmailMessage object.
This is a very slow process, are there any other way to do this?
I would like to get all the mails that I can see in the
preview
Instead of FindItems(), use the ExchangeService.BindToItems() method and provide a collection of the message ids you want in batches. Restrict the property set to only the properties you need. A couple of other thoughts:
- Limit the preview response shape to just the item identifiers since you'll call BindToItems for the properties you need.
- FindItems will only return the first 512 characters of the body.
- Use paging with SearchMailboxes(). Optimal page size will depend on the property set. You'd have to test different page sizes to optimize.

Resources