remp / beam-module
REMP Beam Laravel 包
Requires
- php: ^8.1
- ext-json: *
- ext-pcntl: *
- arrilot/laravel-widgets: ^3.13
- doctrine/dbal: ^3.1
- fideloper/proxy: ^4.4
- fruitcake/laravel-cors: ^v3.0.0
- google/apiclient: ^2.9
- guzzlehttp/guzzle: ^7.0.1
- kouz/laravel-airbrake: ^0.7.0
- laminas/laminas-diactoros: ^2.5
- laracasts/flash: ^3.2
- laravel/framework: ^8.44
- laravelcollective/html: ^6.2
- league/uri: ^6.7
- marc-mabe/php-enum: ^3.0
- matomo/device-detector: ^4.2
- matomo/searchengine-and-social-list: ^3.11
- php-amqplib/php-amqplib: ^v2.12
- predis/predis: ^1.1
- remp/laravel-helpers: *
- remp/laravel-sso: *
- remp/laravel-widgets: *
- remp/remp-commons: *
- sentry/sentry-laravel: ^2.6
- simshaun/recurr: ^5.0
- snowplow/referer-parser: dev-master
- snowplow/referer-parser-php: 0.0.1
- spatie/laravel-searchable: ^1.9
- symfony/cache: ^5.2
- symfony/psr-http-message-bridge: ^v2.1.2
- symfony/yaml: ^6.0
- tightenco/ziggy: ^1.2
- ukfast/laravel-health-check: ^1.5
- yadakhov/insert-on-duplicate-key: ^1.2
- yajra/laravel-datatables-oracle: ^9.18
Requires (Dev)
- barryvdh/laravel-debugbar: ^3.7
- barryvdh/laravel-ide-helper: ^2.10
- facade/ignition: ^2.5
- fakerphp/faker: ^v1.20.0
- laravel/tinker: ^2.5
- mockery/mockery: ^1.4.2
- nunomaduro/collision: ^5.0
- phpunit/phpunit: ^9.3.3
README
Beam 管理员提供了一种在您的网站上显示实时使用统计信息的方式,包括聚合的文章/作者/转化数据,并允许您根据跟踪的数据创建用户细分。
技术描述
仪表板
仪表板为您提供关于您的网站流量的实时数据。这些数据包括
- 目前活跃在您网站上的用户数量(基于过去10分钟内测量的活动)
- 按来源媒体(例如,电子邮件,搜索引擎,内部流量等)拆分的页面浏览量图表,与上一个期间的数据(例如,今天与上周同一天)进行比较。
- 当前访问的文章列表,包括额外属性,如总访问量,转化和阅读文章的时间。
所有这些统计数据都是实时提供的,并每隔几秒自动更新。
为了使仪表板正确工作,您需要
- 在您的网站上包含跟踪JS片段(这将填充今天的图表)
- 通过文章跟踪API将文章元数据推送到Beam
- 在此片段中启用timespent跟踪(
rempConfig.tracker.timeSpent = { "enabled": true}
)。
注意:Timespent跟踪不是强制性的。仪表板可以使用常规页面浏览数据来计算并发数量。如果您不打算跟踪timespent,请参阅此Telegraf配置选项,以便您可以将并发切换到基于页面浏览。
仪表板允许您显示每篇文章的详细信息,包括包含按流量来源媒体拆分的访问量直方图的页面浏览相关图表,并显示与文章相关的活动。
来源媒体标签
可选地,您可以配置页面浏览来源媒体的标签。标签将在仪表板流量(以及文章详细流量)中显示,而不是实际跟踪值。
目前,您可以直接通过编辑数据库表referer_medium_labels
来完成此操作。
账户
账户代表对Beam数据的访问点。目前它没有任何用途,但在将来,您将能够根据每个用户允许的账户配置对数据的访问。
到目前为止,为您的组织创建一个单独的账户(例如,使用您报纸的名称)是完全可以的。
属性
属性是您想要跟踪的单位(网站,子应用,移动应用)。账户可以有多个属性。将来,Beam将允许对选定属性的数据进行跟踪。
每个属性都有一个令牌,需要在JS片段中(rempConfig.token
)使用。
细分
Beam能够根据通过JS片段和后端API跟踪到系统的事件提供基于行为细分。
常规细分
可以通过Web UI创建常规细分。细分构建工具允许您根据多个条件选择,根据这些条件,用户和浏览器(意味着匿名用户也可以细分)将针对特定细分进行检查。
细分构建工具始终仅显示基于已跟踪事件的选择。如果您想创建具有某些特定条件的细分,系统中至少应该有一个事件与条件匹配。
作者细分
如果您的一些读者只对特定作者感兴趣,Beam 可以识别这样的用户并生成 作者细分。每个作者细分包含用户,这些用户通常返回并阅读该细分所属的作者。
由于这些细分计算是计算密集型操作,作者细分是在后端通过运行 php artisan segments:compute-author-segments
来计算的。
每个细分包含根据标准分配给它的用户和浏览器,这些标准可以在 Beam 管理设置页面 (/author-segments/configuration
) 中调整。
默认情况下不会运行此命令(因此不存在作者细分)。需要在需要时手动运行它或定期安排它重新计算细分。我们建议每晚安排计算细分,并在 计划事件 部分中包含 Cron 片段
实体
实体是一个实验性功能,允许您在 Beam 中定义和跟踪对象。它旨在帮助您根据系统中的数据创建细分 - 通过首先将必要的数据推送到 Beam。
让我们以跟踪和基于向您用户发送印刷品的细分为例来解释这个功能。
要开始使用实体,首先运行 EntitySeeder
以将必要项填充到数据库中。
php artisan db:seed --class=EntitySeeder
然后,访问 /entities
并定义您实体的结构。在我们的例子中,这个新实体可以称为 print_delivery
,父实体 user
(因为我们希望为每个用户跟踪它)。每个实体都必须属于另一个实体 - 要么是默认的 user
实体,要么是您的实体之一。
我们可以为这个实体添加一些参数
delivery_date
(datetime)表示尝试投递的时间successful
(布尔值)表示投递是否成功issue_code
(字符串)表示您尝试投递的问题的参考
保存后,此实体将传播到您的 Tracker API,您可以开始跟踪您的实体。Tracker API 还将验证您的有效载荷,以便您不会意外推送无效的实体。
您可以通过运行以下命令测试跟踪新的 print_delivery
(将 property_token
更改为您的)
curl -X POST \ http://tracker.beam.remp.press/track/entity \ -H 'Content-Type: application/json' \ -d '{ "entity_def": { "data": { "delivery_date": "2018-06-05T06:03:05Z", "issue_code": "20180603_DAILY" }, "id": "1", "parent_id": "1122", "name": "print_delivery" }, "system": { "property_token": "1a8feb16-3e30-4f9b-bf74-20037ea8505a", "time": "2018-06-05T06:03:05Z" } }'
API 的描述可以在 Tracker 的 swagger.json
中找到。
截至目前,实体尚未与细分构建器 UI 链接,并且仅存储在 Elasticsearch 中以供以后使用。由于它们是实验性功能,API 可能会在将来更改,不建议在生产中使用。
通讯录
当 Beam 配置与 Mailer(REMP_MAILER_ADDR
已填充)一起工作时,Beam 允许您配置自动生成通讯录。此电子邮件的内容将基于 Beam 自动选择的文章,同时还可以为每个用户分别个性化电子邮件。
当您要添加通讯录时,以下内容是必需的
-
名称。 此通讯录的名称。仅在 Beam 管理中的通讯录列表中使用。
-
细分。 应接收此通讯录的用户的目标细分。由 Mailer 提供细分列表,可能与 Beam 中直接提供的可用细分列表不同(因为 Mailer 可能已注册其他细分提供程序)。
-
生成器。 用于生成电子邮件的 Mailer 生成器。Mailer 中的生成器必须使用
best_performing_articles
键注册。默认情况下,Mailer 提供这样的生成器,并结合非常基本的模板。services: generator: class: Remp\MailerModule\Generators\GeneratorFactory setup: - registerGenerator('best_performing_articles', 'Best performing articles', \Remp\MailerModule\Generators\GenericBestPerformingArticlesGenerator())
-
邮件类型。 新创建的电子邮件必须属于特定的邮件类型(通讯录),这样 Mailer 可以检查用户是否已订阅接收此电子邮件。您应选择这是哪种通讯录。
-
标准。 应该使用什么标准来选择(和排序)新闻稿文章(例如页面浏览量、阅读文章的时间)。
-
时间范围。 应该选择哪个时间范围作为标准。这个时间范围应该与你的重复频率相似或相同,这样你就可以每24小时发送一次过去24小时(时间范围)内的最佳文章。
-
文章数量。 应该选择多少篇文章放入电子邮件中。
-
个性化内容。 是否所有用户都应该收到相同的新闻稿,或者是否每个人都应该收到包含他们尚未阅读的文章的新闻稿。
-
电子邮件主题。 新闻稿的主题是什么(例如,Dennik N - 每日新闻稿)。
-
发件人。 新闻稿的发送者是谁(例如,info@example.com)
-
开始日期。 电子邮件应该何时发送。
-
重复。 如果电子邮件应该重复发送,以及应该多久发送一次。
一旦配置完成,你应该运行(并安排)发送电子邮件的命令
php artisan newsletters:send
文章
Beam为文章提供页面浏览量相关和转换相关统计数据。要显示这些数据,Beam需要你首先推送文章和转换元数据。请参阅文章跟踪和转换跟踪部分,以查看您应该从您的CMS/CRM请求的API调用定义。
如果您已启用Laravel计划程序,并且通过JS片段跟踪页面浏览量,您现在可以显示文章的统计信息。
- 转换统计。 显示给定文章报告的转换数量、收入和平均值。所有内容均可按作者和部分进行筛选。您可以根据文章发布日期和转换日期筛选数据。
- 页面浏览量统计。 显示给定文章的页面浏览量(如果已跟踪)和阅读时间以及相关平均值。所有内容均可按作者和部分进行筛选。您可以根据文章发布日期筛选数据。
转换
转换部分提供有关通过转换跟踪跟踪的单个转换的信息,并允许您根据作者和部分筛选转换。
部分还包括实验性的用户路径功能,该功能尝试提取转换发生之前发生的所有事件的汇总。在其当前状态下,它仅提供支付发生前的活动计数和事件份额。
要开始使用此功能,请运行(并安排)以下命令以首先创建汇总
php artisan conversions:aggregate-events
作者
本部分提供与文章部分类似视图,但区别在于在这里您可以查看每个作者的汇总数据。当您选择特定的作者时,Beam显示给定作者的文章统计信息。
您可以根据文章发布日期筛选数据。
访客
访客部分提供了关于访客来自何处以及使用什么设备的汇总视图。部分允许您根据目标访问日期范围和订阅状态筛选结果,因此您可以看到您的订阅者来自何处,以及您的非付费用户来自何处。
- 设备。 部分允许您根据浏览器和从访客的用户代理中提取的特定设备查看访客的硬件相关统计数据(带访问计数)。
- 来源。 部分允许您查看基于引用者的统计信息,并查看给定来源(主机)或媒体(例如,搜索、内部流量等)的绝对数字。
API文档
梁自身作为追踪数据并以优雅方式显示数据的工具。Beam管理员提供了一些API,用于提供需要持久存储在MySQL中的文章和转换的元数据。
注意:所有Elasticsearch数据都应始终被视为非持久性的,并在必要时进行备份。
所有示例都使用http://beam.remp.press
作为基础域名。请在执行示例之前将主机更改为您使用的域名。
所有示例都使用XXX
作为默认的授权令牌值,请将其替换为在REMP SSO中获得的实际令牌API令牌。
所有请求都应包含(且符合)以下HTTP头。
Content-Type: application/json
Accept: application/json
Authorization: Bearer REMP_SSO_API_TOKEN
API响应可以包含以下HTTP代码
如果可能,响应将包括application/json
编码的有效负载,其中包含进一步解释错误的消息。
POST /api/articles/upsert
(已弃用 - 点击此处查看v2)
您的CMS应跟踪所有与Beam相关的文章更改,以便Beam了解文章、作者是谁以及它属于哪个部分。一旦文章数据可用给Beam,系统就开始链接您通过JS片段跟踪的各种统计信息,以及与Beam相关的数据(例如,标题的A/B测试)。
头部
主体
{ "articles": [ { "external_id": "74565321", // String; Required; ID of article in your CMS, "property_uuid": "7855a8d9-d445-4dc0-8414-dbd7dfd326f9", // String; Required; Beam property token, you can get it in Beam admin - Properties, "title": "10 things you need to know", // String; Required; Primary title of the article, "titles": { // Optional; If A/B test of titles is used, you can track the titles here "A": "10 things you need to know", // Title of variant being tracked with key "A" "B": "10 things everyone hides from you" // Title of variant being tracked with key "B" }, "url": "http://example.com/74565321", // Public and valid URL of the article, "content_type": "blog", // String; Optional; Content type of the article. Default value "article" used if not provided. "authors": [ // Optional "Jon Snow" // Name of the author ], "sections": [ // Optional "Opinions" // Name of the section ], "published_at": "2018-06-05T06:03:05Z" // RFC3339 formatted datetime } ] }
示例
curl
curl -X POST \ http://beam.remp.press/api/articles/upsert \ -H 'Accept: application/json' \ -H 'Authorization: Bearer XXX' \ -H 'Content-Type: application/json' \ -d '{ "articles": [ { "external_id": "74565321", "property_uuid": "1a8feb16-3e30-4f9b-bf74-20037ea8505a", "title": "10 things you need to know", "titles": { "A": "10 things you need to know", "B": "10 things everyone hides from you" }, "url": "http://example.com/74565321", "content_type": "blog", "authors": [ "Jon Snow" ], "sections": [ "Opinions" ], "tags": [ "Elections 2020" ], "published_at": "2018-06-05T06:03:05Z" } ] }'
原始PHP
$payload = [ "articles" => [ [ "external_id" => "74565321", "property_uuid" => "1a8feb16-3e30-4f9b-bf74-20037ea8505a", "title" => "10 things you need to know", "titles" => [ "A" => "10 things you need to know", "B" => "10 things everyone hides from you" ], "url" => "http://example.com/74565321", "content_type" => "blog", "authors" => [ "Jon Snow" ], "sections" => [ "Opinions" ], "tags" => [ "Elections 2020" ], "published_at" => "2018-06-05T06:03:05Z", ] ] ]; $jsonPayload = json_encode($payload); $context = stream_context_create([ 'http' => [ 'method' => 'POST', 'header' => "Content-Type: type=application/json\r\n" . "Accept: application/json\r\n" . "Content-Length: " . strlen($jsonPayload) . "\r\n" . "Authorization: Bearer XXX", 'content' => $jsonPayload, ] ] ); $response = file_get_contents("http://beam.remp.press/api/articles/upsert ", false, $context); // process response (raw JSON string)
响应
{ "data": [ { "id": 123902, "external_id": "74565321", "property_uuid": "1a8feb16-3e30-4f9b-bf74-20037ea8505a", "title": "10 things you need to know", "url": "http://example.com/74565321", "content_type": "blog", "image_url": null, "published_at": "2018-06-05 06:03:05", "pageviews_all": 0, "pageviews_signed_in": 0, "pageviews_subscribers": 0, "timespent_all": 0, "timespent_signed_in": 0, "timespent_subscribers": 0, "created_at": "2019-05-17 11:43:04", "updated_at": "2019-05-17 11:43:04", "authors": [ { "name": "Jon Snow", "created_at": "2019-05-17 11:43:04", "updated_at": "2019-05-17 11:43:04" } ], "sections": [ { "name": "Opinions", "created_at": "2019-05-17 11:43:04", "updated_at": "2019-05-17 11:43:04" } ], "tags": [ { "name": "Elections 2020", "created_at": "2019-05-17 11:43:04", "updated_at": "2019-05-17 11:43:04" } ], } ] }
任何创建/更新的匹配都基于文章的external_id
。您可以自由地多次更新文章。
POST /api/v2/articles/upsert
您的CMS应跟踪所有与Beam相关的文章更改,以便Beam了解文章、作者是谁以及它属于哪个部分。一旦文章数据可用给Beam,系统就开始链接您通过JS片段跟踪的各种统计信息,以及与Beam相关的数据(例如,标题的A/B测试)。
头部
主体
{ "articles": [ { "external_id": "74565321", // String; Required; ID of article in your CMS, "property_uuid": "7855a8d9-d445-4dc0-8414-dbd7dfd326f9", // String; Required; Beam property token, you can get it in Beam admin - Properties, "title": "10 things you need to know", // String; Required; Primary title of the article, "titles": { // Optional; If A/B test of titles is used, you can track the titles here "A": "10 things you need to know", // Title of variant being tracked with key "A" "B": "10 things everyone hides from you" // Title of variant being tracked with key "B" }, "url": "http://example.com/74565321", // Public and valid URL of the article, "content_type": "blog", // String; Optional; Content type of the article. Default value "article" used if not provided. "authors": [ // Optional { "external_id": "1", // String; Required; External id of the author "name": "Jon Snow" // String; Required; Name of the author } ], "sections": [ // Optional { "external_id": "1", // String; Required; External id of the section "name": "Opinions" // String; Required; Name of the section } ], "tags": [ // Optional { "external_id": "1", // String; Required; External id of the tag "name": "Elections 2020", // String; Required; Name of the tag, "categories": [ // Optional { "external_id": "1", // String; Required; External id of the tag category "name": "USA" // String; Required; Name of the tag category } ] } ], "published_at": "2018-06-05T06:03:05Z" // RFC3339 formatted datetime } ] }
示例
curl
curl -X POST \ http://beam.remp.press/api/v2/articles/upsert \ -H 'Accept: application/json' \ -H 'Authorization: Bearer XXX' \ -H 'Content-Type: application/json' \ -d '{ "articles": [ { "external_id": "74565321", "property_uuid": "1a8feb16-3e30-4f9b-bf74-20037ea8505a", "title": "10 things you need to know", "titles": { "A": "10 things you need to know", "B": "10 things everyone hides from you" }, "url": "http://example.com/74565321", "content_type": "blog", "authors": [ { "external_id": "1", "name": "Jon Snow" } ], "sections": [ { "external_id": "1", "name": "Opinions" } ], "tags": [ { "external_id": "1", "name": "Elections 2020", "categories": [ { "external_id": "1", "name": "USA" } ] } ], "published_at": "2018-06-05T06:03:05Z" } ] }'
原始PHP
$payload = [ "articles" => [ [ "external_id" => "74565321", "property_uuid" => "1a8feb16-3e30-4f9b-bf74-20037ea8505a", "title" => "10 things you need to know", "titles" => [ "A" => "10 things you need to know", "B" => "10 things everyone hides from you" ], "url" => "http://example.com/74565321", "content_type" => "blog", "authors" => [ [ "external_id" => "1", "name" => "Jon Snow" ] ], "sections" => [ [ "external_id" => "1", "name" => "Opinions" ] ], "tags" => [ [ "external_id" => "1", "name" => "Elections 2020" , "categories" => [ [ "external_id" => "1", "name" => "USA" ] ] ] ], "published_at" => "2018-06-05T06:03:05Z", ] ] ]; $jsonPayload = json_encode($payload); $context = stream_context_create([ 'http' => [ 'method' => 'POST', 'header' => "Content-Type: type=application/json\r\n" . "Accept: application/json\r\n" . "Content-Length: " . strlen($jsonPayload) . "\r\n" . "Authorization: Bearer XXX", 'content' => $jsonPayload, ] ] ); $response = file_get_contents("http://beam.remp.press/api/v2/articles/upsert ", false, $context); // process response (raw JSON string)
响应
{ "data": [ { "id": 123902, "external_id": "74565321", "property_uuid": "1a8feb16-3e30-4f9b-bf74-20037ea8505a", "title": "10 things you need to know", "url": "http://example.com/74565321", "content_type": "blog", "image_url": null, "published_at": "2018-06-05 06:03:05", "pageviews_all": 0, "pageviews_signed_in": 0, "pageviews_subscribers": 0, "timespent_all": 0, "timespent_signed_in": 0, "timespent_subscribers": 0, "created_at": "2019-05-17 11:43:04", "updated_at": "2019-05-17 11:43:04", "authors": [ { "external_id": "1", "name": "Jon Snow", "created_at": "2019-05-17 11:43:04", "updated_at": "2019-05-17 11:43:04" } ], "sections": [ { "external_id": "1", "name": "Opinions", "created_at": "2019-05-17 11:43:04", "updated_at": "2019-05-17 11:43:04" } ], "tags": [ { "external_id": "1", "name": "Elections 2020", "created_at": "2019-05-17 11:43:04", "updated_at": "2019-05-17 11:43:04", "tag_categories": [ { "external_id": "1", "name": "USA" } ] } ], } ] }
任何创建/更新的匹配都基于文章的external_id
。您可以自由地多次更新文章。
POST /api/articles/read
基于筛选器列出已读文章。
头部
主体
{ "user_id": "5", // String; Required if browser_id not set; ID of user in your CMS, "browser_id": "qwerty123", // String; Required if user_id not set; ID of browser that made article pageview, "from": "2021-06-05T06:03:05Z", // RFC3339-based time from which to take pageviews "to": "2021-07-05T06:03:05Z" // RFC3339-based time to which to take pageviews }
示例
curl
curl -X POST \ http://beam.remp.press/api/articles/read \ -H 'Accept: application/json' \ -H 'Authorization: Bearer XXX' \ -H 'Content-Type: application/json' \ -d '{ "user_id": "5", "browser_id": "qwerty123", "from": "2021-06-05T06:03:05Z", "to": "2021-07-05T06:03:05Z" }'
原始PHP
$payload = [ "user_id" => "5", "browser_id" => "qwerty123", "from" => "2021-06-05T06:03:05Z", "to" => "2021-07-05T06:03:05Z" ]; $jsonPayload = json_encode($payload); $context = stream_context_create([ 'http' => [ 'method' => 'POST', 'header' => "Content-Type: type=application/json\r\n" . "Accept: application/json\r\n" . "Content-Length: " . strlen($jsonPayload) . "\r\n" . "Authorization: Bearer XXX", 'content' => $jsonPayload, ] ] ); $response = file_get_contents("http://beam.remp.press/api/articles/read ", false, $context); // process response (raw JSON string)
响应
[ { "article_id": "2546241", "browser_id": "qwerty123", "time": "2021-06-10T06:03:05Z", "user_id": "5" }, { "article_id": "2551289", "browser_id": "qwerty123", "time": "2021-06-09T06:03:05Z", "user_id": "5" } ]
POST api/conversions/upsert
Beam管理员提供关于文章/作者性能的统计信息。使用的指标之一是转换。此端点存储最小的转换数据。扩展数据应通过Tracker API(请参阅Tracker的swagger.json
文件中的/track/commerce
定义)额外跟踪。
头部
主体
{ "conversions": [ { "article_external_id": "74565321", // String; Required; ID of article in your CMS, "transaction_id": "8743320112", // String; Required; ID of transaction (unique for each transaction), "amount": 17.99, // Numeric; Required; Nominal amount of the transaction, e.g. 10.0 "currency": "EUR", // String; Required; Currency of the transaction, e.g. ",EUR" "paid_at": "2018-06-05T12:03:05Z", // String; Required; RFC3339 formatted datetime with date of the transaction, "user_id": "74412" // Optional; Identifier of user who made a transaction } ] }
示例:
curl
curl -X POST \ http://beam.remp.press/api/conversions/upsert \ -H 'Accept: application/json' \ -H 'Authorization: Bearer XXX' \ -H 'Content-Type: application/json' \ -d '{ "conversions": [ { "article_external_id": "74565321", "transaction_id": "8743320112", "amount": 17.99, "currency": "EUR", "paid_at": "2018-06-05T12:03:05Z", "user_id": "74412" } ] }'
原始PHP
$payload = [ "conversions" => [ [ "article_external_id" => "74565321", "transaction_id" => "8743320112", "amount" => 17.99, "currency" => "EUR", "paid_at" => "2018-06-05T12:03:05Z", "user_id" => "74412" ] ] ]; $jsonPayload = json_encode($payload); $context = stream_context_create([ 'http' => [ 'method' => 'POST', 'header' => "Content-Type: type=application/json\r\n" . "Accept: application/json\r\n" . "Content-Length: " . strlen($jsonPayload) . "\r\n" . "Authorization: Bearer XXX", 'content' => $jsonPayload, ] ] ); $response = file_get_contents("http://beam.remp.press/api/conversions/upsert ", false, $context); // process response (raw JSON string)
响应
{ "data": [ { "id": 67297, "article_id": 123902, "user_id": "74412", "amount": 17.99, "currency": "EUR", "paid_at": "2018-06-05 12:03:05", "transaction_id": "8743320112", "events_aggregated": true, "created_at": "2019-05-17 11:47:18", "updated_at": "2019-05-17 12:00:21" } ] }
POST api/articles/top
Beam管理员提供关于文章性能的统计信息。此端点返回按页面浏览量排序的前置文章。您可以根据内容类型、部分、作者、标签或标签类别筛选文章。
头部
主体
{ "from": "2020-08-10T08:09:18+00:00", // RFC3339-based start time from which to take pageviews to this today "limit": 3, // limit how many top articles this endpoint returns "content_type": "article", // String; OPTIONAL; filters articles by content_type "published_from": "2020-08-10T08:09:18+00:00", // RFC3339-based time; OPTIONAL; filter articles according theirs publishing date "sections": { // OPTIONAL; filters from which sections take articles (use either external_id or name arrays, not both) "external_id": ["Section external id"], // String; section external IDs "name": ["Section title"] // String; section names }, "authors": { // OPTIONAL; filters from which authors take articles (use either external_id or name arrays, not both) "external_id": ["author external id"], // String; author external IDs "name": ["author name"] // String; author names }, "tags": { // OPTIONAL; filters articles with tags (use either external_id or name arrays, not both) "external_id": ["tag external id"], // String; tag external IDs "name": ["tag name"] // String; tag names }, "tag_categories": { // OPTIONAL; filters articles with tag categories (use either external_id or name arrays, not both) "external_id": ["tag category external id"], // String; tag category external IDs "name": ["tag category name"] // String; tag category names } }
示例:
curl
curl --location --request POST 'http://beam.remp.press/api/articles/top' \ --header 'Content-Type: application/json' \ --header 'Accept: application/json' \ --header 'Authorization: Bearer XXX' \ --data-raw '{ "from": "2020-08-10T08:09:18+00:00", "limit": 3, "content_type": "article", "sections": { "external_id": ["1"] }, "authors": { "external_id": ["123"] }, "tags": { "external_id": ["10"] }, "tag_categories": { "external_id": ["1"] } }'
原始PHP
$payload = [ "from" => "2020-08-10T08:09:18+00:00", "limit" => 3, "content_type" => "article", "sections" => [ "name" => ["Blog"] ], "authors" => [ "name" => ["John Doe"] ], "tags" => [ "name" => ["News"] ], "tag_categories" => [ "name" => ["Europe"] ] ]; $jsonPayload = json_encode($payload); $context = stream_context_create([ 'http' => [ 'method' => 'POST', 'header' => "Content-Type: type=application/json\r\n" . "Accept: application/json\r\n" . "Content-Length: " . strlen($jsonPayload) . "\r\n" . "Authorization: Bearer XXX", 'content' => $jsonPayload, ] ] ); $response = file_get_contents("http://beam.remp.press/api/articles/top", false, $context); // process response (raw JSON string)
响应
[ { "external_id": "1411843", "pageviews": 274 }, { "external_id": "1443988", "pageviews": 150 }, { "external_id": "1362607", "pageviews": 45 } ]
POST api/v2/articles/top
Beam管理员提供关于文章性能的统计信息。此端点返回按页面浏览量排序的前置文章。您可以根据内容类型、部分、作者、标签或标签类别筛选文章。
您可以为每个筛选器类别组合多个筛选器。类别内和类别之间的筛选器以AND
连接,筛选器中的值以OR
连接。
头部
主体
{ "from": "2020-08-10T08:09:18+00:00", // RFC3339-based start time from which to take pageviews to this today "limit": 3, // limit how many top articles this endpoint returns "content_type": "article", // String; OPTIONAL; filters articles by content_type "sections": [ // OPTIONAL; filters from which sections take articles (use either external_id or name arrays, not both); filters joined with AND {"external_ids": ["Section external ids"]}, // String; section external IDs; values joined with OR {"names": ["Section titles"]} // String; section names; joined with OR; values joined with OR ], "authors": [ // OPTIONAL; filters from which authors take articles (use either external_id or name arrays, not both); filters joined with AND {"external_ids": ["author external ids"]}, // String; author external IDs; values joined with OR {"names": ["author names"]} // String; author names; joined with OR; values joined with OR ], "tags": [ // OPTIONAL; filters articles with tags (use either external_id or name arrays, not both); filters joined with AND {"external_ids": ["tag external ids"]}, // String; tag external IDs; values joined with OR {"names": ["tag names"]} // String; tag names; values joined with OR ], "tag_categories": [ // OPTIONAL; filters articles with tag categories (use either external_id or name arrays, not both); filters joined with AND {"external_ids": ["tag category external ids"]}, // String; tag category external IDs; values joined with OR {"names": ["tag category names"]} // String; tag category names; values joined with OR ] }
示例:
curl
curl --location --request POST 'http://beam.remp.press/api/v2/articles/top' \ --header 'Content-Type: application/json' \ --header 'Accept: application/json' \ --header 'Authorization: Bearer XXX' \ --data-raw '{ "from": "2020-08-10T08:09:18+00:00", "limit": 3, "content_type": "article", "sections": [ {"external_ids": ["1", "2"]}, {"names": ["World"]} ], "authors": [ {"external_ids": ["123"]} ], "tags": [ {"external_ids": ["10"]} ], "tag_categories": [ {"external_ids": ["1"]} ] }'
原始PHP
$payload = [ "from" => "2020-08-10T08:09:18+00:00", "limit" => 3, "content_type" => "article", "sections" => [ ["names" => ["Blog"]] ], "authors" => [ ["names" => ["John Doe"]] ], "tags" => [ ["names" => ["News"]] ], "tag_categories" => [ ["names" => ["Europe"]] ] ]; $jsonPayload = json_encode($payload); $context = stream_context_create([ 'http' => [ 'method' => 'POST', 'header' => "Content-Type: type=application/json\r\n" . "Accept: application/json\r\n" . "Content-Length: " . strlen($jsonPayload) . "\r\n" . "Authorization: Bearer XXX", 'content' => $jsonPayload, ] ] ); $response = file_get_contents("http://beam.remp.press/api/v2/articles/top", false, $context); // process response (raw JSON string)
响应
[ { "external_id": "1411843", "pageviews": 274 }, { "external_id": "1443988", "pageviews": 150 }, { "external_id": "1362607", "pageviews": 45 } ]
POST api/authors/top
Beam管理员提供关于作者性能的统计信息。此端点返回按页面浏览量排序的前置作者。您可以根据内容类型、部分、标签或标签类别筛选作者。
头部
主体
{ "from": "2020-08-10T08:14:09+00:00", // RFC3339-based start datetime from which to take pageviews to this today "limit": 3, // limit how many top authors this endpoint returns "content_type": "article", // String; OPTIONAL; filters articles by content_type "sections": { // OPTIONAL; filters from which sections take articles (use either external_id or name arrays, not both) "external_id": ["Section external id"], // String; section external IDs "name": ["Section title"] // String; section names }, "tags": { // OPTIONAL; filters articles with tags (use either external_id or name arrays, not both) "external_id": ["Tag external id"], // String; tag external IDs "name": ["Tag title"] // String; tag names }, "tag_categories": { // OPTIONAL; filters articles with tag categories (use either external_id or name arrays, not both) "external_id": ["tag category external id"], // String; tag category external IDs "name": ["tag category name"] // String; tag category names } }
示例:
curl
curl --location --request POST 'http://beam.remp.press/api/authors/top' \ --header 'Content-Type: application/json' \ --header 'Accept: application/json' \ --header 'Authorization: Bearer XXX' \ --data-raw '{ "from": "2020-08-10T08:14:09+00:00", "limit": 3, "content_type": "article", "sections": { "external_id": ["22"] }, "tags": { "external_id": ["10"] }, "tag_categories": { "external_id": ["1"] } }'
原始PHP
$payload = [ "from" => "2020-08-10T08:14:09+00:00", "limit" => 3, "content_type" => "article", "sections" => [ "name" => ["Blog"] ], "tags" => [ "name" => ["News"] ], "tag_categories" => [ "name" => ["Europe"] ] ]; $jsonPayload = json_encode($payload); $context = stream_context_create([ 'http' => [ 'method' => 'POST', 'header' => "Content-Type: type=application/json\r\n" . "Accept: application/json\r\n" . "Content-Length: " . strlen($jsonPayload) . "\r\n" . "Authorization: Bearer XXX", 'content' => $jsonPayload, ] ] ); $response = file_get_contents("http://beam.remp.press/api/authors/top", false, $context); // process response (raw JSON string)
响应
[ { "external_id": 100, "name": "Example Author", "pageviews": 23000 } ]
POST api/v2/authors/top
Beam管理员提供关于作者性能的统计信息。此端点返回按页面浏览量排序的前置作者。您可以根据内容类型、部分、标签或标签类别筛选作者。
您可以为每个筛选器类别组合多个筛选器。类别内和类别之间的筛选器以AND
连接,筛选器中的值以OR
连接。
头部
主体
{ "from": "2020-08-10T08:14:09+00:00", // RFC3339-based start datetime from which to take pageviews to this today "limit": 3, // limit how many top authors this endpoint returns "content_type": "article", // String; OPTIONAL; filters articles by content_type "sections": [ // OPTIONAL; filters from which sections take articles (use either external_id or name arrays, not both); filters joined with AND {"external_ids": ["Section external ids"]}, // String; section external IDs; values joined with OR {"names": ["Section titles"]} // String; section names; values joined with OR ], "tags": [ // OPTIONAL; filters articles with tags (use either external_id or name arrays, not both); filters joined with AND {"external_ids": ["Tag external ids"]}, // String; tag external IDs; values joined with OR {"names": ["Tag titles"]} // String; tag names; values joined with OR ], "tag_categories": [ // OPTIONAL; filters articles with tag categories (use either external_id or name arrays, not both); filters joined with AND {"external_ids": ["tag category external ids"]}, // String; tag category external IDs; values joined with OR {"names": ["tag category names"]} // String; tag category names; values joined with OR ] }
示例:
curl
curl --location --request POST 'http://beam.remp.press/api/v2/authors/top' \ --header 'Content-Type: application/json' \ --header 'Accept: application/json' \ --header 'Authorization: Bearer XXX' \ --data-raw '{ "from": "2020-08-10T08:14:09+00:00", "limit": 3, "content_type": "article", "sections": [ {"external_ids": ["22"]} ], "tags": [ {"external_ids": ["10"]} ], "tag_categories": [ {"external_ids": ["1"]} ] }'
原始PHP
$payload = [ "from" => "2020-08-10T08:14:09+00:00", "limit" => 3, "content_type" => "article", "sections" => [ ["names" => ["Blog"]] ], "tags" => [ ["names" => ["News"]] ], "tag_categories" => [ ["names" => ["Europe"]] ] ]; $jsonPayload = json_encode($payload); $context = stream_context_create([ 'http' => [ 'method' => 'POST', 'header' => "Content-Type: type=application/json\r\n" . "Accept: application/json\r\n" . "Content-Length: " . strlen($jsonPayload) . "\r\n" . "Authorization: Bearer XXX", 'content' => $jsonPayload, ] ] ); $response = file_get_contents("http://beam.remp.press/api/v2/authors/top", false, $context); // process response (raw JSON string)
响应
[ { "external_id": 100, "name": "Example Author", "pageviews": 23000 } ]
POST api/tags/top
Beam管理员提供关于标签性能的统计信息。此端点返回按页面浏览量排序的前置帖子标签。您可以根据内容类型、部分、作者或标签类别筛选标签。
头部
主体
{ "from": "2020-08-10T08:14:09+00:00", // RFC3339-based start datetime from which to take pageviews to this today "limit": 3, // limit how many top tags this endpoint returns "content_type": "article", // String; OPTIONAL; filters articles by content_type "sections": { // OPTIONAL; filters from which sections take articles (use either external_id or name arrays, not both) "external_id": ["Section external id"], // String; section external IDs "name": ["Section title"] // String; section external_id }, "authors": { // OPTIONAL; filters from which authors take articles (use either external_id or name arrays, not both) "external_id": ["author external id"], // String; section external IDs "name": ["author name"] // String; section external_id }, "tag_categories": { // OPTIONAL; filters articles with tag categories (use either external_id or name arrays, not both) "external_id": ["tag category external id"], // String; tag category external IDs "name": ["tag category name"] // String; tag category names } }
示例:
curl
curl --location --request POST 'http://beam.remp.press/api/tags/top' \ --header 'Content-Type: application/json' \ --header 'Accept: application/json' \ --header 'Authorization: Bearer XXX' \ --data-raw '{ "from": "2020-08-10T08:14:09+00:00", "limit": 3, "content_type": "article", "sections": { "external_id": ["1"] }, "authors": { "external_id": ["123"] }, "tag_categories": { "external_id": ["1"] } }'
原始PHP
$payload = [ "from" => "2020-08-10T08:14:09+00:00", "limit" => 3, "content_type" => "article", "sections" => [ "name" => ["Blog"] ], "authors" => [ "name" => ["John Doe"] ], "tag_categories" => [ "name" => ["Europe"] ] ]; $jsonPayload = json_encode($payload); $context = stream_context_create([ 'http' => [ 'method' => 'POST', 'header' => "Content-Type: type=application/json\r\n" . "Accept: application/json\r\n" . "Content-Length: " . strlen($jsonPayload) . "\r\n" . "Authorization: Bearer XXX", 'content' => $jsonPayload, ] ] ); $response = file_get_contents("http://beam.remp.press/api/tags/top", false, $context); // process response (raw JSON string)
响应
[ { "name": "ekonomika", "pageviews": 4000, "external_id": "1" }, { "name": "covid19", "pageviews": 3000, "external_id": "2" }, { "name": "brexit", "pageviews": 2000, "external_id": "3" } ]
POST api/v2/tags/top
Beam管理员提供关于标签性能的统计信息。此端点返回按页面浏览量排序的前置帖子标签。您可以根据内容类型、部分、作者或标签类别筛选标签。
您可以为每个筛选器类别组合多个筛选器。类别内和类别之间的筛选器以AND
连接,筛选器中的值以OR
连接。
头部
主体
{ "from": "2020-08-10T08:14:09+00:00", // RFC3339-based start datetime from which to take pageviews to this today "limit": 3, // limit how many top tags this endpoint returns "content_type": "article", // String; OPTIONAL; filters articles by content_type "sections": [ // OPTIONAL; filters from which sections take articles (use either external_id or name arrays, not both); filters joined with AND {"external_ids": ["Section external ids"]}, // String; section external IDs; values joined with OR {"names": ["Section titles"]} // String; section external_id; values joined with OR ], "authors": [ // OPTIONAL; filters from which authors take articles (use either external_id or name arrays, not both); filters joined with AND {"external_ids": ["author external ids"]}, // String; section external IDs; values joined with OR {"names": ["author names"]} // String; section external_id; values joined with OR ], "tag_categories": [ // OPTIONAL; filters articles with tag categories (use either external_id or name arrays, not both); filters joined with AND {"external_ids": ["tag category external ids"]}, // String; tag category external IDs; values joined with OR {"names": ["tag category names"]} // String; tag category names; values joined with OR ] }
示例:
curl
curl --location --request POST 'http://beam.remp.press/api/v2/tags/top' \ --header 'Content-Type: application/json' \ --header 'Accept: application/json' \ --header 'Authorization: Bearer XXX' \ --data-raw '{ "from": "2020-08-10T08:14:09+00:00", "limit": 3, "content_type": "article", "sections": [ {"external_ids": ["1"]} ], "authors": [ {"external_ids": ["123"]} ], "tag_categories": [ {"external_ids": ["1"]} ] }'
原始PHP
$payload = [ "from" => "2020-08-10T08:14:09+00:00", "limit" => 3, "content_type" => "article", "sections" => [ ["names" => ["Blog"]] ], "authors" => [ ["names" => ["John Doe"]] ], "tag_categories" => [ ["names" => ["Europe"]] ] ]; $jsonPayload = json_encode($payload); $context = stream_context_create([ 'http' => [ 'method' => 'POST', 'header' => "Content-Type: type=application/json\r\n" . "Accept: application/json\r\n" . "Content-Length: " . strlen($jsonPayload) . "\r\n" . "Authorization: Bearer XXX", 'content' => $jsonPayload, ] ] ); $response = file_get_contents("http://beam.remp.press/api/v2/tags/top", false, $context); // process response (raw JSON string)
响应
[ { "name": "ekonomika", "pageviews": 4000, "external_id": "1" }, { "name": "covid19", "pageviews": 3000, "external_id": "2" }, { "name": "brexit", "pageviews": 2000, "external_id": "3" } ]
POST api/pageviews/histogram
Beam管理员提供满足日期范围天数的筛选条件的文章的页面浏览量直方图。您可以根据内容类型、部分、作者、标签或标签类别筛选文章。
您可以为每个筛选器类别组合多个筛选器。类别内和类别之间的筛选器以AND
连接,筛选器中的值以OR
连接。
头部
主体
{ "from": "2020-08-10", // date from which take pageviews including "to": "2020-08-12", // date to which take pageviews "content_type": "article", // String; OPTIONAL; filters articles by content_type "sections": [ // OPTIONAL; filters from which sections take articles (use either external_id or name arrays, not both); filters joined with AND {"external_ids": ["Section external ids"]}, // String; section external IDs; values joined with OR {"names": ["Section titles"]} // String; section names; joined with OR; values joined with OR ], "authors": [ // OPTIONAL; filters from which authors take articles (use either external_id or name arrays, not both); filters joined with AND {"external_ids": ["author external ids"]}, // String; author external IDs; values joined with OR {"names": ["author names"]} // String; author names; joined with OR; values joined with OR ], "tags": [ // OPTIONAL; filters articles with tags (use either external_id or name arrays, not both); filters joined with AND {"external_ids": ["tag external ids"]}, // String; tag external IDs; values joined with OR {"names": ["tag names"]} // String; tag names; values joined with OR ], "tag_categories": [ // OPTIONAL; filters articles with tag categories (use either external_id or name arrays, not both); filters joined with AND {"external_ids": ["tag category external ids"]}, // String; tag category external IDs; values joined with OR {"names": ["tag category names"]} // String; tag category names; values joined with OR ] }
示例:
curl
curl --location --request POST 'http://beam.remp.press/api/pageviews/histogram' \ --header 'Content-Type: application/json' \ --header 'Accept: application/json' \ --header 'Authorization: Bearer XXX' \ --data-raw '{ "from": "2020-08-10", "to": "2020-08-12", "content_type": "article", "sections": [ {"external_ids": ["1", "2"]}, {"names": ["World"]} ], "authors": [ {"external_ids": ["123"]} ], "tags": [ {"external_ids": ["10"]} ], "tag_categories": [ {"external_ids": ["1"]} ] }'
原始PHP
$payload = [ "from" => "2020-08-10", "to" => "2020-08-12", "content_type" => "article", "sections" => [ ["names" => ["Blog"]] ], "authors" => [ ["names" => ["John Doe"]] ], "tags" => [ ["names" => ["News"]] ], "tag_categories" => [ ["names" => ["Europe"]] ] ]; $jsonPayload = json_encode($payload); $context = stream_context_create([ 'http' => [ 'method' => 'POST', 'header' => "Content-Type: type=application/json\r\n" . "Accept: application/json\r\n" . "Content-Length: " . strlen($jsonPayload) . "\r\n" . "Authorization: Bearer XXX", 'content' => $jsonPayload, ] ] ); $response = file_get_contents("http://beam.remp.press/api/pageviews/histogram", false, $context); // process response (raw JSON string)
响应
[ { "date": "2020-08-10", "pageviews": 274 }, { "date": "2020-08-11", "pageviews": 150 } ]
GET /api/articles
返回指定ID或外部ID的文章列表。
头部
参数
示例
curl
curl -X GET \ http://beam.remp.press/api/articles?external_ids=123,231 \ -H 'Accept: application/json' \ -H 'Authorization: Bearer XXX' \
原始PHP
$context = stream_context_create([ 'http' => [ 'method' => 'GET', 'header' => "Accept: application/json\r\n" . "Authorization: Bearer XXX", ] ] ); $response = file_get_contents("http://beam.remp.press/api/articles?external_ids=123,231", false, $context); // process response (raw JSON string)
响应
{ "data": [ { "id": 123, "external_id": "123", "property_uuid": "a6c80469-464d-4118-830c-0448494ada86", "title": "Test article title", "url": "http:\/\/example.com\/test-article\/", "content_type": "article", "image_url": "http:\/\/example.com\/test-article\/image.jpg", "published_at": "2021-04-13 09:26:10", "pageviews_all": 7505, "pageviews_signed_in": 4492, "pageviews_subscribers": 4029, "timespent_all": 900715, "timespent_signed_in": 789643, "timespent_subscribers": 758675, "created_at": "2021-04-13 09:26:13", "updated_at": "2021-04-14 06:27:13" } ] }
GET /api/authors
返回作者列表。
头部
参数
示例
curl
curl -X GET \ http://beam.remp.press/api/authors \ -H 'Accept: application/json' \ -H 'Authorization: Bearer XXX' \
原始PHP
$context = stream_context_create([ 'http' => [ 'method' => 'GET', 'header' => "Accept: application/json\r\n" . "Authorization: Bearer XXX", ] ] ); $response = file_get_contents("http://beam.remp.press/api/authors", false, $context); // process response (raw JSON string)
响应
{ "data": [ { "external_id": "ext-1", "name": "Mr. Damian White", "created_at": "2020-08-14T12:18:37.000000Z", "updated_at": "2020-08-14T12:18:37.000000Z" }, { "external_id": "ext-2", "name": "Mac Schroeder", "created_at": "2020-08-14T12:18:37.000000Z", "updated_at": "2020-08-14T12:18:37.000000Z" }, // ... ] }
GET /api/conversions
返回转换列表。
头部
参数
示例
curl
curl -X GET \ http://beam.remp.press/api/conversions?conversion_from=2018-06-05T06:03:05Z \ -H 'Accept: application/json' \ -H 'Authorization: Bearer XXX' \
原始PHP
$context = stream_context_create([ 'http' => [ 'method' => 'GET', 'header' => "Accept: application/json\r\n" . "Authorization: Bearer XXX", ] ] ); $response = file_get_contents("http://beam.remp.press/api/conversions?conversion_from=2018-06-05T06:03:05Z", false, $context); // process response (raw JSON string)
响应
{ "data": [ { "id": 1441, "article_id": 114, "user_id": null, "amount": 25, "currency": "EUR", "paid_at": "2020-11-07T06:30:53.000000Z", "transaction_id": "08ad9d77-bbaf-31d2-9db1-04225ded1e72", "events_aggregated": true, "source_processed": true, "created_at": "2020-11-09T09:57:37.000000Z", "updated_at": "2020-11-09T09:57:37.000000Z", "article_external_id": "cd14dfb5-3af2-3a73-b6ab-78b9dca2e975" }, //.... ] }
GET /api/sections
返回部分列表。
头部
参数
示例
curl
curl -X GET \ http://beam.remp.press/api/sections \ -H 'Accept: application/json' \ -H 'Authorization: Bearer XXX' \
原始PHP
$context = stream_context_create([ 'http' => [ 'method' => 'GET', 'header' => "Accept: application/json\r\n" . "Authorization: Bearer XXX", ] ] ); $response = file_get_contents("http://beam.remp.press/api/sections", false, $context); // process response (raw JSON string)
响应
{ "data": [ { "external_id": null, "name": "reinger", "created_at": "2020-08-14T12:18:36.000000Z", "updated_at": "2020-08-14T12:18:36.000000Z" }, { "external_id": null, "name": "blick", "created_at": "2020-08-14T12:18:36.000000Z", "updated_at": "2020-08-14T12:18:36.000000Z" } // ... ] }
GET /api/tags
返回标签列表。
头部
参数
示例
curl
curl -X GET \ http://beam.remp.press/api/tags \ -H 'Accept: application/json' \ -H 'Authorization: Bearer XXX' \
原始PHP
$context = stream_context_create([ 'http' => [ 'method' => 'GET', 'header' => "Accept: application/json\r\n" . "Authorization: Bearer XXX", ] ] ); $response = file_get_contents("http://beam.remp.press/api/tags", false, $context); // process response (raw JSON string)
响应
{ "data": [ { "external_id": null, "name": "reinger", "created_at": "2020-08-14T12:18:36.000000Z", "updated_at": "2020-08-14T12:18:36.000000Z" }, { "external_id": null, "name": "blick", "created_at": "2020-08-14T12:18:36.000000Z", "updated_at": "2020-08-14T12:18:36.000000Z" } // ... ] }