Skip to content
This repository has been archived by the owner on Mar 30, 2022. It is now read-only.

zikwall/huawei-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

52 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Huawei API

Installation

composer require zikwall/huawei-api - not available at this time

develop mode

{
    "minimum-stability": "dev",
    "repositories": [
        {
            "type": "git",
            "url": "https://github.com/zikwall/huawei-api.git"
        }
    ],
    "require": {
        "zikwall/huawei-api": "dev-master"
    }
}

Example usage API

use zikwall\huawei_api\HuaweiClient;

$client = new HuaweiClient();
$client->setRedirectUri('localhost');
$client->setClientId('00000000000000');
$client->setClientSecret('f00000000000000000000000000000000000000000000000000000000');
$client->setProductId('00000000000000000000');

// or setup in initialization step

$client = new HuaweiClient([
    'credentials' => [
        'client_id' => '00000000000000',
        'client_secret' => 'f00000000000000000000000000000000000000000000000000000000',
    ],  
]);

// or set config properties from default configuration JSON file (download from huawei dashboard)
$client->setAuthConfigFile('agconnect-services.json');
// or
$client->setAuthConfig([
    'client_id' => '00000000000000',
    'client_secret' => 'f00000000000000000000000000000000000000000000000000000000',
]);

print_r($client->fetchAccessToken());

use zikwall\huawei_api\services\HuaweiServiceSubscription;
use zikwall\huawei_api\services\HuaweiServiceOrder;

$subscriptions = new HuaweiServiceSubscription($client->getAccessToken(), $client->getRegion());

print_r($subscriptions->getSubscription('token', 'id'));

$orders = new HuaweiServiceOrder($client->getAccessToken(), $client->getRegion());

print_r($orders->verifyToken('id', 'token'));

OAuth2

<a href="<?= $client->makeAuthUrl() ?>">Login</a>