PHP code example of artur-stepien / wargaming-papi

1. Go to this page and download the library: Download artur-stepien/wargaming-papi 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/ */

    

artur-stepien / wargaming-papi example snippets

 php


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


$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());
	
}
 php


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


$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());
	
}
 php


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


$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());
	
}