1. Go to this page and download the library: Download m4aax16/kinguin-laravel 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/ */
m4aax16 / kinguin-laravel example snippets
use m4aax16\kinguin\Client;
use m4aax16\kinguin\Product;
use m4aax16\kinguin\Order;
use m4aax16\kinguin\User;
use m4aax16\kinguin\Region;
$kinguinClient = new Client("YOUR-API-KEY-HERE");
//This function will fetch 25 products per Page, it's a default value by Kinguin
$page = 1;
$products = Product::getPage($page); // $page is NOT
foreach($products['results'] as $product)
{
$product['kinguinId']; //Accessing product attribute Id => Output : INT
$product['name']; //Accessing product attribute name => Output : STRING
//accessing other objects of product
//Example : Screenshots
$screenshots = $product['screenshots'];
foreach($screenshots as $screenshot)
{
$screenshot['url_original'];
}
}
$itemsPerPage = 100; // Max. products per page is 100
$pageCount = Product::getPagesCount($itemsPerPage); // $itemsPerPage is NOT
$productId = 5; //set the kinguinId of product
$product = Product::getProduct($productId); //returns detailed information about this product
Region::getRegions(); //returns all regions, the array key is the id of the region
$regions = Region::getRegions();
foreach($regions as $regionId => $value)
{
echo $regionId; //region id
echo " ";
echo $value; //region name
echo "</br>";
}
$regionId = 1; // Id 1 is "Europe"
$region = Region::getRegionById($regionId);
echo $region; //Output will be a STRING
$balance = User::getBalance(); // Output is a FLOAT, Example: 20439.99
$productId = 195; // ProductId is Warhammer for Steam
$qty = 1;
$price = 0.59;
//All parameter all erId: 26983294"
// $couponCode is a optional parameter
$keys = Order::getOrderKeys($dispatchId);
/* Example Output :
0:
serial "SOME-ACTIVATION-KEY"
type "text/plain" //Key types are text or image
name "Warhammer 40,000: Space Marine Steam CD Key"
kinguinId 195
*/
$kgOrderId = "9XQ3FFRQKVL";
$keys = Order::getOrderKeyById($kgOrderId);
/* Example Output :
0
serial "Real_1942 XYYG8-4GBCC-ILMFM"
type "text/plain"
name "Real 1942 Steam CD Key"
kinguinId 57083
productId "5c9b787a2539a4e8f184354a"
offerId "5fa56a6d9c2506000196e12a"
*/
$productId = 0; //set the kinguinId of product
$product = Product::getProduct($productId); //returns detailed information about this product
//Check the method getStatusCode exists
if(method_exists($product,'getStatusCode')){
//If the status code is higher than 200
if($product->getStatusCode() > 200){
//This method return the full error message inline
$errFull = $product->getData()->error;
//This method return only the Kinguin Error Code
$errCode = $product->getData()->response->code;
//This method return the error message
$errMessage = $product->getData()->response->message;
echo "Full Error : ".$errFull."</br>";
echo "Error Code : ".$errCode."</br>";
echo "Error Message : ".$errMessage."</br>";
/* Example ouputs :
1. If the client is not authorized =>
Full Error : Client error: `GET https://gateway.kinguin.net/esa/api/v1/products/0` resulted in a `401 Unauthorized` response: {"code":2401,"message":"Full authentication is
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.