PHP code example of anvilm / spworlds

1. Go to this page and download the library: Download anvilm/spworlds 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/ */

    

anvilm / spworlds example snippets


use Anvilm\SPWorlds\API;

$SPWorlds = new API($id, $token);

$SPWorlds->APIService->cardInfo()

$discordId = 'discord_id'; //Discord id игрока

$SPWorlds->APIService->getUsername($discordId);

$username = 'user_name'; //Ник игрока

$SPWorlds->APIService->getCards($username);

$SPWorlds->APIService->getOwner();

//Массив предметов на покупку
$items = [
    [
        'name' => 'item_name', //Имя предмета
        'count' => '10', //Количество предметов
        'price' => '1', //Цена за штуку
        'comment' => 'some comment' //Комментарий
    ]
];

$redirectUrl = 'https://redirect.url'; //Ссылка для переадрессации пользователя
$webhookUrl = 'https://webhook.url'; //Вебхук

$data = 'some data'; //Любая информация

$SPWorlds->APIService->payment($items, $redirectUrl, $webhookUrl, $data);

$receiver = 'receiver card'; //Номер карты получателя
$ammount = '10'; //Сумма
$comment = 'some comment'; //Комментарий к переводу

$SPWorlds->APIService->transaction($receiver, $ammount, $comment);

$webhook = 'https://webhook.url'; //Вебхук

$SPWorlds->APIService->setWebhook($webhook);

$body = $request->getContent(); //JSON тело запроса
$hashHeader = $request->header('X-Body-Hash'); //Хеш тела запроса

$SPWorlds->APIService->validateHash($body, $hashHeader);

$SPWorlds->APIService->getAuthorization();
bash
php artisan vendor:publish --provider='AnvilM\SPWorlds\Providers\SPWorldsServiceProvider'