1. Go to this page and download the library: Download cubicnode/steamdata-sdk-php 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/ */
cubicnode / steamdata-sdk-php example snippets
declare(strict_types=1);
nums\ApiVersion;
use Cubicnode\Cloud\Steamdata\Enums\Region;
use Cubicnode\Cloud\Steamdata\Enums\ServiceRoutes\ImageModeration;
use Cubicnode\Cloud\Steamdata\Enums\ServiceRoutes\IpInfo;
use Cubicnode\Cloud\Steamdata\Enums\ServiceType;
use Cubicnode\Cloud\Steamdata\Enums\SignatureVersion;
use Cubicnode\Cloud\Steamdata\ServiceApiClient;
use Cubicnode\Cloud\Steamdata\ServiceApiConfig;
use GuzzleHttp\Exception\RequestException;
use Psr\Http\Message\ResponseInterface;
$serviceApiConfig = new ServiceApiConfig();
$serviceApiConfig->setGatewayUrl('https://api.steamdata.cloud.cubicnode.com');
$serviceApiConfig->setRegion(Region::AP_EAST_1->value); // 设定区域
$serviceApiConfig->setApiVersion(ApiVersion::V1_0->value); // 设定 API 版本
$serviceApiConfig->setSignatureVersion(SignatureVersion::SD1->value); // 设定签名版本
$serviceApiConfig->setAccessKeyId('<your-access-key-id>'); // 设置 AccessKeyId
$serviceApiConfig->setSecretAccessKey('<your-secret-access-key>'); // 设置 SecretAccessKey
$serviceApiConfig->setInstanceId('<your-instance-id>'); // 设置实例 ID
// 也可以这样设置
$serviceApiConfig = new ServiceApiConfig(
gatewayUrl: 'https://api.steamdata.cloud.cubicnode.com',
region: Region::AP_EAST_1->value,
apiVersion: ApiVersion::V1_0->value,
signatureVersion: SignatureVersion::SD1->value,
accessKeyId: '<your-access-key-id>',
secretAccessKey: '<your-secret-access-key>',
instanceId: '<your-instance-id>',
)
// 创建客户端
$serviceApiClient = new ServiceApiClient($serviceApiConfig);
$serviceApiClient->setServiceType(ServiceType::IMAGE_MODERATION)
->send(ImageModeration::GET_IMAGE_SCORE_ASYNC, [
'image' => __DIR__.'/test.png',
'callback_url' => 'https://example.com/callback',
'marker_id' => '0123456789',
])
->then(function (ResponseInterface $response) {
echo $response->getBody()->getContents(); // 返回一个 json 字符串
})
->catch(function (RequestException $exception) {
echo $exception->getResponse()->getBody()->getContents(); // 一般情况下,返回一个 json 字符串
})
->wait();
bash
composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.