PHP code example of remp / beam-module
1. Go to this page and download the library: Download remp/beam-module library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
remp / beam-module example snippets
$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)
$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)
$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)
$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)
$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)
$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)
$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)
$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)
$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)
$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)
$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)
$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)
$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)
$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)
$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)
$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)
bash
php artisan db:seed --class=EntitySeeder
php artisan newsletters:send
bash
php artisan conversions:aggregate-events
shell
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"
}'
shell
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"]
}
}'
shell
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"]}
]
}'
shell
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"]
}
}'
shell
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"]}
]
}'
shell
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"]
}
}'
shell
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"]}
]
}'
shell
curl -X GET \
http://beam.remp.press/api/conversions?conversion_from=2018-06-05T06:03:05Z \
-H 'Accept: application/json' \
-H 'Authorization: Bearer XXX' \