如何查询来自Codecademy用户的Google URL短ener API请求数量?
Let's kick things off with a key, up-to-date fact: the Google URL Shortener API was officially deprecated in March 2018 and completely shut down in March 2019. It’s no longer operational—so you can’t send any requests to it, let alone pull stats on POST request counts from specific users like those on Codecademy.
But even when the API was active, tracking POST requests from Codecademy users specifically wasn’t a built-in feature. Here’s the breakdown:
- The API’s core functionality was limited to shortening URLs and providing basic analytics for individual shortened links (like total click counts). It had no tools to track the origin of incoming requests or aggregate request counts by source (like Codecademy’s platform).
- To count POST requests from Codecademy users back when the API worked, you would have needed to set up your own intermediary server. Here’s how that would have worked:
- Have Codecademy users send their POST requests to your server instead of directly to Google’s API.
- Log each incoming request on your server, using headers like
Refererto identify requests coming from Codecademy’s exercise pages. - Forward the request to the Google URL Shortener API, retrieve the generated short link, and send it back to the user.
- Analyze your server’s logs later to tally up the total number of requests from Codecademy users.
Even if you tried to retroactively count requests by looking at existing shortened links created during the Codecademy exercise, that wouldn’t give you an accurate number. Multiple users might have shortened the same long URL, and the API’s stats didn’t distinguish between different creators of the same short link—so you couldn’t map those links back to individual POST requests.
内容的提问来源于stack exchange,提问作者user8028410

