Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nicekiwi/census
Helper package to interact with the Planetside 2 Census service by Daybreak Game Company.
https://github.com/nicekiwi/census
Last synced: 26 days ago
JSON representation
Helper package to interact with the Planetside 2 Census service by Daybreak Game Company.
- Host: GitHub
- URL: https://github.com/nicekiwi/census
- Owner: nicekiwi
- License: mit
- Created: 2022-11-12T00:37:03.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-05-13T12:56:46.000Z (over 1 year ago)
- Last Synced: 2023-08-04T04:54:50.520Z (over 1 year ago)
- Language: PHP
- Homepage:
- Size: 47.9 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Census
[![Unit Tests](https://github.com/nicekiwi/census/actions/workflows/tests.yml/badge.svg)](https://github.com/nicekiwi/census/actions/workflows/tests.yml)
Helper package to interact with the Planetside 2 Census service by Daybreak Game Company.
- Steam events from the Census Websocket API
- Query the Census API endpoints
- Useful Enums
- Faction
- World
- Zone
- Platform
- MetagameEvent
- MetagameEventState## Requirements
- PHP 8.2
- Laravel 10
- [Service ID](https://census.daybreakgames.com/#devSignup) from Daybreak Game Company## Installation
```
composer require nicekiwi/census
```
#### Publish config
```
php artisan vendor:publish --provider="Nicekiwi\Census\Providers\CensusServiceProvider"
```#### Add Service ID to .env
```
CENSUS_SERVICE_ID=your-service-id
```## Usage
### StreamClient
Stream kills from all worlds on the PC platform.
```php
use Nicekiwi\Census\StreamClient;
use Nicekiwi\Census\Enums\Platform;
use Nicekiwi\Census\Enums\MetagameEvent;$client = new StreamClient(Platform::PC);
$client->subscribe(
$client->subscribePayload([MetagameEvent::CHARACTER_DEATH]),
function($payload, $exception) {
if ($exception) {
echo $exception->getMessage();
echo $payload;
} else {
var_dump($payload['attacker_character_id'] . ' killed ' . $payload['character_id']);
}
}
);/*
[
'attacker_character_id' => '54200000000000000',
'attacker_fire_mode_id' => '1',
'attacker_loadout_id' => '1',
'attacker_vehicle_id' => '0',
'attacker_weapon_id' => '26003',
'character_id' => '54200000000000000',
'character_loadout_id' => '1',
'character_vehicle_id' => '0',
'facility_id' => '0',
'is_headshot' => '0',
'event_name' => 'Death',
'timestamp' => '1510000000',
'world_id' => '1',
'zone_id' => '2',
]
*/
```### ApiClient
Query the API for character information from the PC platform.```php
use Nicekiwi\Census\Enums\Platform;
use Nicekiwi\Census\ApiClient;$client = new ApiClient(Platform::PC);
$ids = ['5428010618020694593'];
$detail = $client->request('character', [
'character_id' => implode(',', $ids),
'c:resolve' => 'world',
'c:show' => 'character_id,world_id'
]);var_dump($detail);
/*
[
[
'character_id' => '5428010618020694593',
'world_id' => '17'
]
]
*/
```## Testing
```
composer test
```