firegore2/clash-royale-php
Composer 安装命令:
composer require firegore2/clash-royale-php
包简介
THE UNOFFICIAL PHP Clash Royale API
README 文档
README
THE UNOFFICIAL PHP Clash Royale Wrapper
INFO
This work with the back-end of this page Clash Royale API
REQUIREMENTS
PHP 5.5 or greater
Composer
INSTALLATION
In the root of your project (the same path which contains the composer file) enter
composer update
to install the library or use
composer require firegore2/clash-royale-php
to install in your own project.
TOKEN
You need a developer token to use the API.
These are the steps to obtain it:
- Go to the discord server of the API
- Go to the #developer-key channel.
- Type
?crapikey get - The bot will send you a DM (direct message) along with your key.
METHODS
API Document See examples folder for more information
getPlayer()
<?php
use CR\Api;
require 'vendor/autoload.php';
/**
* Return all the information about the given users tag
* @method getPlayer
* @param array $player Array with the id of the profiles
* @param array $keys Array with the exact parameters to request
* @param array $exclude Array with the exact parameters to exclude in the request
* @return Player[] Array of Player Objects if given more than one profile, else return one Player Object
*/
$token = "YOUR_TOKEN";
$api = new Api($token);
try{
$player = $api->getPlayer(["JSDFS45","ASDAD123"]);
d($player); //This display the array with Player objects
}
catch(Exception $e){
d($e);
}
getClan()
<?php
use CR\Api;
require 'vendor/autoload.php';
/**
* Return all the information about the given clan tag
* @method getClan
* @param array $clan Array with the tag of the clans
* @return Clan[] Array of Clan Objects if given more than one profile, else return one Clan Object
*/
$token = "YOUR_TOKEN";
$api = new Api($token);
try{
$clans = $api->getClan(["clan_tag1","clan_tag2"]);
d($clans); //This display the Array of Clan objects
}
catch(Exception $e){
d($e);
}
getTop()
<?php
use CR\Api;
require 'vendor/autoload.php';
/**
* Return all information about the top players or clans
* @method getTop
* @param array $top Array with values "players" or/and "clans"
* @return array Array with key of respectives top type ("players" or "clans") and with their values an array with "lastUpdate"
* of the top list and the respective array with the respective objects type ("players" = array CR\Objects\Profile)
*/
$token = "YOUR_TOKEN";
$api = new Api($token);
try{
$tops = $api->getTop(["players","clans"]);
d($tops); //This display the array with Profile objects
}
catch(Exception $e){
d($e);
}
clanSearch
<?php
ini_set('max_execution_time', 3000);
use CR\Api;
require 'vendor/autoload.php';
$token = "YOUR_TOKEN";
$api = new Api($token);
try {
/**
* Search clans by their attributes
* @method clanSearch
* @param string $name (Optional)Clan name text search.
* @param int $score (Optional) Minimum clan score.
* @param int $minMembers (Optional) Minimum number of members. 0-50
* @param int $maxMembers (Optional) Maximum number of members. 0-50
* @return ClanSearch[] $clanSearch Returns an array of Clan objects that match the search parameters
*/
$clansSearch = $api->clanSearch("INFRAMUNDO",35140,44,46);
foreach ($clansSearch as $clanSearch) {
/**
* ClanSearch object
*
* @method string getTag() Returns the tag of the clan
* @method string getName() Returns the name of the clan
* @method string getType() Returns the admission type of the clan
* @method int getScore() Returns the score of the clan
* @method int getMemberCount() Returns the members number of the clan
* @method int getRequiredScore() Returns the required score to enter the clan
* @method int getDonations() Returns the total donations per week of the clan
* @method AllianceBadge getBadge() Returns the AllianceBadge Object of the clan
* @method Location getLocation() Returns the Location Object of the clan
*/
$tag = $clanSearch->getTag();
$name = $clanSearch->getName();
$type = $clanSearch->getType();
$score = $clanSearch->getScore();
$memberCount = $clanSearch->getMemberCount();
$requiredScore = $clanSearch->getRequiredScore();
$donations = $clanSearch->getDonations();
/**
* AlianceBadge object
*
*
* @method string getName() Returns the name of the badge
* @method string getCategory() Returns the category name of the badge
* @method int getId() Returns the id of the badge
* @method string getImage() Returns the image url of the badge
*
*
*/
$badge = $clanSearch->getBadge();
$name = $badge->getName();
$category = $badge->getCategory();
$id = $badge->getId();
$image = $badge->getImage();
/**
* Location object
* @method string getName() Returns the name of the location.
* @method bool getIsCountry() Returns true if the location is a country. otherwise returns false.
* @method string getCode() Returns the country/continent code
*
*
* @method string getContinent() Returns the continent name
* @method string getContinentCod() Returns the continent code
* @method string getCountry() Returns the country name
* @method string getCountryCode() Returns the country code
*/
$location = $clanSearch->getLocation();
$country = $location->getCountry();
$continent = $location->getContinent();
$countryCode = $location->getCountryCode();
$continentCode = $location->getContinentCode();
d(
$clanSearch,
$tag,
$name,
$type,
$score,
$memberCount,
$requiredScore,
$donations,
$badge,
$name,
$category,
$id,
$image,
$location,
$country,
$continent,
$countryCode,
$continentCode
);
}
} catch (\Exception $e) {
d($e);
}
TEST
firegore2/clash-royale-php 适用场景与选型建议
firegore2/clash-royale-php 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.84k 次下载、GitHub Stars 达 12, 最近一次更新时间为 2017 年 12 月 05 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「clash royale」 「clash royale php」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 firegore2/clash-royale-php 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 firegore2/clash-royale-php 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 firegore2/clash-royale-php 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Alfabank REST API integration
Clash Royale Api PHP SDK
PHP Wrapper for Clash Royale API https://github.com/cr-api/cr-api
Zero-dependency raw PHP DNS resolver, domain-ownership verification, and intoDNS/MxToolbox-style diagnostics. Queries authoritative nameservers directly over sockets — never trusts the recursive cache for ownership checks.
Abstraction Layer for Clash of Clans API Results
A lightweight plain-PHP framework for database-backed CRUD APIs.
统计信息
- 总下载量: 1.84k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 12
- 点击次数: 6
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2017-12-05