对于一个博客来说,我想获得上个月的十大热门文章。我想从Matomo上获取数据,因为Matomo已经在跟踪访问量,并且有一个API。我从来没有使用过这个API,所以我一直在阅读文档并尝试一些东西。我可以通过API的 Actions.getPageUrls
方法。然而,当我尝试使用 segment=^http://example.org/post
我仍然从其他URL中获取数据。它看起来像是在会话上进行过滤,并将至少有1个页面符合过滤条件的会话中的所有数据返回。
我使用的完整URL是:: http://example.org/matomo/index.php?&module=API&token_auth=12345&method=Actions.getPageUrls&format=json&idSite=1&period=month&date=today&expanded=1&segment=pageUrl%3D%5Ehttp%253A%252F%252Fexample.org%252Fpost
. 我也试过少用或不用URL编码的段,但似乎没有什么区别。如果我使用一个不存在的URL,我得到一个空数组返回。
我是不是做错了什么?是否有其他方法可以只获取URL以 http:/example.orgpost? 还是我必须自己筛选数据才能得到我想要的页面?
我使用的是Matomo 3.13.5版本。
我想明白了。没有必要使用 segment
. 这可以通过使用 flat
, filter_column
和 filter_pattern
参数。
设置 flat=1
将使所有的页面以一个数组的形式返回,而不是分层返回。
使用 filter_column
和 filter_pattern
我可以过滤结果。
我现在使用的网址是: http://example.org/matomo/index.php?&module=API&token_auth=12345&method=Actions.getPageUrls&format=json&idSite=1&period=month&date=today&flat=1&filter_column=label&filter_pattern=%5E%2Fpost%2F
. 这正是我想要的。
未编码的模式是 ^/post/
因此,这将过滤掉任何不以 /post/
.