PHP code example of zimo-xiao / zuggr-cloud-sdk

1. Go to this page and download the library: Download zimo-xiao/zuggr-cloud-sdk 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/ */

    

zimo-xiao / zuggr-cloud-sdk example snippets




$config = [
    'app_id' => 'foo',
    'app_secret' => 'bar',
    'client_config' => [
        'node' => 'zcbj'
    ]
];

/**
 * Instantiates a new ZuggrCloud super-class object.
 *
 * @param CacheInterface $cache
 * @param array $config
 * @param bool $mock
 *
 * @throws ZuggrCloudException
 */
$zuggr = new ZuggrCloud\ZuggrCloud($cache, $config, false);

/**
 * Makes request to Zuggr Cloud and returns the result
 *
 * @param string $uri
 * @param array $data
 * @param array $headers
 * @param bool $appAuth
 * @param bool $returnRequestOauth
 * @return array
 */

// for safety reasons, request_oauth will not be returned by default

$zuggr->get('app/oauth/info', [], [], true); // app token auto-magically appears in request header when $appAuth = true

$adminOauth = $zuggr->post('admin/oauth/login', [
    'username' => 'foo',
    'password' => 'bar'
]);

// if you set 'token' in data or 'Authorization' in header
// $appAuth is auto-magically set to false
// but for good measures, write the full params
$adminInfo = $zuggr->get('admin/oauth/info', [], [
    'Authorization' => 'Bearer '.$adminOauth['access_token']
], false);