artur-stepien/wargaming-papi 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

artur-stepien/wargaming-papi

Composer 安装命令:

composer require artur-stepien/wargaming-papi

包简介

Provides a useful interface to connect and use Wargaming Public API

README 文档

README

Basic PHP library handling Wargaming Public API. Uses namespace to get data sources so it is compatible with all sources (WoT, Blitz, WGN, WoWp and also WoWs) and all servers (EU,NA,ASIA,RU,KR). All it needs is application_id that can be obtained here https://eu.wargaming.net/developers/applications/ (for EU).

Requirements

  • PHP 7.0+
  • CURL

Sample usage

<?php

use Wargaming\Language\EN as EnglishLanguage;
use Wargaming\Server\EU as EuropeanServer;

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

// API Instance where YOUR_APPLICATION_ID is your application_id registered for the server you use.
$lang = new EnglishLanguage();
$server = new EuropeanServer('YOUR_APPLICATION_ID');
$api = new Wargaming\API($lang, $server);

// Test how it works
try {
	$data = $api->get('wgn/clans/list', ['search'=>'PSQD','fields'=>'name,tag,clan_id']);
	
	// Display info about WoT Clan PSQD
	var_dump($data);
	
} catch (Exception $e) {

	die($e->getMessage());
	
}

Sample ETag usage

<?php

use Wargaming\Language\EN as EnglishLanguage;
use Wargaming\Server\EU as EuropeanServer;

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

// API Instance where YOUR_APPLICATION_ID is your application_id registered for the server you use.
$lang = new EnglishLanguage();
$server = new EuropeanServer('YOUR_APPLICATION_ID');
$api = new Wargaming\API($lang, $server);

// Test how it works
try {
	// As a 4th param provide ETag. If tag of a clan S3AL wasn't changed method will return true. If it changed new data will be returned.
	$info = $api->get('wgn/clans/info', ['clan_id'=>'500034335','fields'=>'tag'], false, '813ac115749538da9b3b61fd4069fd44');
	
	var_dump($info);die;
	
} catch( Exception $e) {
	
	exit('Error: '.$e->getMessage());
	
}

How to get ETag from API request

<?php

use Wargaming\Language\EN as EnglishLanguage;
use Wargaming\Server\EU as EuropeanServer;

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

// API Instance where YOUR_APPLICATION_ID is your application_id registered for the server you use.
$lang = new EnglishLanguage();
$server = new EuropeanServer('YOUR_APPLICATION_ID');
$api = new Wargaming\API($lang, $server);

// Test how it works
try {
	// Set 5th param to boolean TRUE. That way method will return array with following format: ['headers'=>[],'data'=>StdClass]
	$info = $api->get('wgn/clans/info', ['clan_id'=>'500034335','fields'=>'tag'], false, null, true);

	// Get response headers. Remember to store ETag without quotes cause $api->get() method add those when ETag is provided.
	var_dump($info['headers']['ETag']);die;
	
} catch( Exception $e) {
	
	exit('Error: '.$e->getMessage());
	
}

News

1.4.1 - 2022-05-09

  • Allow chaining in set methods.
  • Simplified some of the conditions.
  • Fixed few typos in documentation.

1.4.0 - 2021-06-08

  • Prepared for use in dependency injection.
  • Added a public function setSSLVerification(bool $state) method to change SSL connection verification status (CURLOPT_SSL_VERIFYPEER).
  • Changed api instance declaration to allow multiple servers
  • Added server instance declaration to allow injected application id (api key)

1.3.1 - 2018-02-26

Creating composer package.

1.3 - 2017-10-09

Moving to PHP7, changing code to PSR.

1.2 - 2016-02-06

From now if CURL return an error class will throw exception with that error message. Also added support for ETag (Documentation) and HTTP headers.

1.1 - 2015-08-20

Moved to CURL for requests. Speed boost shoold be from 50% - 150% cause of reusing connection. Checked on my WN8 calculation class. Regular calculation takes 0.32s

1.04 - 2015-08-19

Fixed few error messages.

1.03 - 2015-08-17

Fixed error handling for associative arrays, added new error messages.

1.02 - 2015-08-17

Added new parameter to API::get() called $assoc. If this parameter is set to true, function will return associative array instead of object/array of objects.

artur-stepien/wargaming-papi 适用场景与选型建议

artur-stepien/wargaming-papi 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.19k 次下载、GitHub Stars 达 8, 最近一次更新时间为 2018 年 02 月 26 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「wot」 「wargaming」 「world of tanks」 「wg」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 artur-stepien/wargaming-papi 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 artur-stepien/wargaming-papi 我们能提供哪些服务?
定制开发 / 二次开发

基于 artur-stepien/wargaming-papi 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 1.19k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 8
  • 点击次数: 23
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 8
  • Watchers: 5
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-3.0-or-later
  • 更新时间: 2018-02-26