如何跟踪用户发送给Web服务或API的请求数量?

时间:2021-10-31 14:08:20

How many requests have been sent or how many times any user has requested data from particular web service? I want to track the count the records like as google analytics.

已发送了多少请求或任何用户从特定Web服务请求数据的次数?我想跟踪谷歌分析等记录的计数。

suppose I have created a web service like as follow.

假设我创建了一个如下的Web服务。

function myWebServices() {
  $data = array();
  $data['usersInfo'] = 'lorem Ipsum';
  $data['status'] = '1';
  return json_encode($data);
}

I have sent URL of this web service to my vendors, they access this function and get the data. But I also want to track the vendor's request, how many times they have sent.

我已将此Web服务的URL发送给我的供应商,他们访问此功能并获取数据。但我也想跟踪供应商的请求,他们发送了多少次。

Is there is any way to track this like as google analytics?

有没有办法像谷歌分析一样跟踪这个?

1 个解决方案

#1


0  

You can trigger an event via an HTTP request each time you receive an incoming API request.

每次收到传入的API请求时,您都可以通过HTTP请求触发事件。

The URL would be something like this:

URL将是这样的:

https://www.google-analytics.com/collect?v=1&cid=[SOME-USER-ID]&tid=UA-XXXXXXX-1&t=event&ec=[EVENT-CATEGORY]&ea=[EVENT-ACTION]&cs=[EVENT-SOURCE]

Mind that [SOME-USER-ID] param is required. You can read further on https://developers.google.com/analytics/devguides/collection/protocol/v1/reference

请注意,[SOME-USER-ID]参数是必需的。您可以在https://developers.google.com/analytics/devguides/collection/protocol/v1/reference上进一步阅读。

#1


0  

You can trigger an event via an HTTP request each time you receive an incoming API request.

每次收到传入的API请求时,您都可以通过HTTP请求触发事件。

The URL would be something like this:

URL将是这样的:

https://www.google-analytics.com/collect?v=1&cid=[SOME-USER-ID]&tid=UA-XXXXXXX-1&t=event&ec=[EVENT-CATEGORY]&ea=[EVENT-ACTION]&cs=[EVENT-SOURCE]

Mind that [SOME-USER-ID] param is required. You can read further on https://developers.google.com/analytics/devguides/collection/protocol/v1/reference

请注意,[SOME-USER-ID]参数是必需的。您可以在https://developers.google.com/analytics/devguides/collection/protocol/v1/reference上进一步阅读。