patryqhyper/spaceis-php-sdk

此包已被废弃且不再维护。作者建议使用 spacecode.pl/spaceis-php-sdk 包代替。

SpaceIs.pl 的 PHP SDK

1.0.0 2021-11-28 23:03 UTC

This package is auto-updated.

Last update: 2022-03-19 16:42:04 UTC


README

#SpaceIS PHP SDK

SpaceIs v3 API 的简单 PHP SDK

访问 API v3 文档: https://docs.spaceis.pl/api

每个响应都可能抛出

LicenseExpiredException(httpCode 402),

NotFoundException(httpCode 400),

RateLimitException(httpCode 429),

ServerErrorException(httpCode 500),

UnauthorizedException(httpCode 401)。

使用方法

require __DIR__ .'/vendor/autoload.php';

use PatryQHyper\SpaceIs\SpaceIs;

$spaceIs = new SpaceIs('apiKey', 'apiUrl (optional)');

# Servers
$spaceIs->getServers();
$spaceIs->getServer('serverId/serverSlug');
$spaceIs->getCommands('serverId', 'serverToken');
$spaceIs->getLatestBuys('serverId/serverSlug', '(int) limit (optional, default:10)');
$spaceIs->getRichest('serverId/serverSlug', '(int) limit (optional, default:10)');

# Variants
$spaceIs->getVariants('serverId/serverSlug', 'productId');

# Payments
$spaceIs->initPayment('serverId/serverSlug', 'productId', 'variantId', 'nick', 'method', 'email (required if method != sms)', 'sms_code (required if method == sms)', 'discountCodeId (optional)', 'additionalParameter'); //throws PaymentInitException
$spaceIs->getTransactionInfo('transactionId', 'mode(info/extended)');

# Subpages
$spaceIs->getSubpage('subpageSlug');

# Discount codes
$spaceIs->getDiscountCode('discountCode');

# Vouchers
$spaceIs->voucherRedeem('nick', 'voucherCode'); //Throws: VoucherNotFoundException and VoucherUsedException

# User
$spaceIs->me();