r4nkt
Search…
Installation
First, grab the latest stable version via composer:
1
$ composer require r4nkt/laravel-r4nkt-sdk
Copied!
The service provider will automatically register itself.
To publish the configuration file, you must use the following command:
1
php artisan vendor:publish --provider="R4nkt\\LaravelR4nkt\\LaravelR4nktServiceProvider" --tag="laravel-r4nkt-sdk-config"
Copied!
Here are the contents of the published configuration file, config/r4nkt.php:
1
return [
2
3
/*
4
|--------------------------------------------------------------------------
5
| Base URL
6
|--------------------------------------------------------------------------
7
|
8
| This determines the base URL for the API that the SDK will use. Generally
9
| speaking, you shouldn't ever need to set or change.
10
|
11
*/
12
13
'base_url' => env('R4NKT_BASE_URL', 'https://api.r4nkt.com/v1'),
14
15
/*
16
|--------------------------------------------------------------------------
17
| API Token
18
|--------------------------------------------------------------------------
19
|
20
| R4nkt requires that you use an API token when communicating with its API.
21
| Make one at the r4nkt API settings page: https://r4nkt.com/settings#/api
22
|
23
*/
24
25
'api_token' => env('R4NKT_API_TOKEN'),
26
27
/*
28
|--------------------------------------------------------------------------
29
| Game ID
30
|--------------------------------------------------------------------------
31
|
32
| R4nkt also requires that you specify the game ID for each API call. Find
33
| this at the game configuration settings: https://r4nkt.com/settings/games
34
|
35
*/
36
37
'game_id' => env('R4NKT_GAME_ID'),
38
39
/*
40
|--------------------------------------------------------------------------
41
| Webhook Signing Secret
42
|--------------------------------------------------------------------------
43
|
44
| R4nkt will sign webhooks using a secret. You can find the secret used for
45
| individual games at the game configuration settings:
46
| - https://r4nkt.com/settings/games
47
|
48
*/
49
50
'signing_secret' => env('R4NKT_SIGNING_SECRET'),
51
52
/*
53
|--------------------------------------------------------------------------
54
| Custom Player ID Resolver
55
|--------------------------------------------------------------------------
56
|
57
| This class is responsible for determining the player's custom ID.
58
|
59
| This class should implement
60
| `R4nkt\Laravel\Support\CustomPlayerIdResolver\CustomPlayerIdResolver`
61
|
62
*/
63
64
'custom_player_id_resolver' => \R4nkt\Laravel\Support\CustomPlayerIdResolver\PrimaryKeyCustomPlayerIdResolver::class,
65
66
/*
67
|--------------------------------------------------------------------------
68
| Custom Player ID Decoder
69
|--------------------------------------------------------------------------
70
|
71
| This class is responsible for decoding the player's custom ID.
72
|
73
| This class should implement
74
| `R4nkt\Laravel\Support\CustomPlayerIdDecoder\CustomPlayerIdDecoder`
75
|
76
*/
77
78
'custom_player_id_decoder' => \R4nkt\Laravel\Support\CustomPlayerIdDecoder\PrimaryKeyCustomPlayerIdDecoder::class,
79
80
/*
81
|--------------------------------------------------------------------------
82
| Date/Time UTC Resolver
83
|--------------------------------------------------------------------------
84
|
85
| This class is responsible for resolving the date/time UTC value to a
86
| properly formatted string.
87
|
88
| This class should implement
89
| `R4nkt\Laravel\Support\DateTimeUtcResolver\DateTimeUtcResolver`
90
|
91
*/
92
93
'date_time_utc_resolver' => \R4nkt\Laravel\Support\DateTimeUtcResolver\DefaultDateTimeUtcResolver::class,
94
95
/*
96
|--------------------------------------------------------------------------
97
| Webhook Jobs
98
|--------------------------------------------------------------------------
99
|
100
| Here you can define the job that should be run when a certain webhook
101
| hits your application.
102
|
103
| You can find a list of R4nkt webhook types here:
104
| - https://r4nkt.com/docs/webhooks/events
105
|
106
*/
107
108
'jobs' => [
109
// 'badge-earned' => \App\Jobs\R4nktWebhooks\HandleBadgeEarned::class,
110
// ...
111
],
112
113
];
Copied!
You should set the signing_secret value for the specific game you are interested in receiving webhooks from.
Finally, you should set up routing. The route that is set up here should match the webhook URL for the specific game you are interested in receiving webhooks from. To do so, you must pass this route using the following command in your app's routes file:
1
Route::R4nktWebhooks('configured-webhook-route');
Copied!
This command registers a POST route to a package controller.
Because r4nkt has no way of getting a CSRF token, you must add that route to the $except array of the VerifyCsrfToken middleware like so:
1
protected $except = [
2
'configured-webhook-route',
3
];
Copied!
Both the webhook secret and URL values can be found on the games management page.

Copy link
Contents