PHP code example of herojhc / xxh-sdk

1. Go to this page and download the library: Download herojhc/xxh-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/ */

    

herojhc / xxh-sdk example snippets

 php-cli
php artisan vendor:publish --provider="XinXiHua\SDK\XXHServiceProvider" --tag="xxh-sdk-config"
 php-cli
php artisan vendor:publish --provider="XinXiHua\SDK\XXHServiceProvider" --tag="xxh-sdk-migrations"

php artisan migrate
 php
protected $primaryKey = 'user_id';
 php
XXH::routes();
 php


namespace App\Http\Middleware;

use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;

class VerifyCsrfToken extends Middleware
{
    /**
     * The URIs that should be excluded from CSRF verification.
     *
     * @var array
     */
    protected $except = [
        //
        'serve'
    ];
}
 php


/**
 * Created by PhpStorm.
 * User: JHC
 * Date: 2018-07-24
 * Time: 11:51
 */

namespace XinXiHua\SDK\Services;


use Illuminate\Support\Facades\Log;
use XinXiHua\SDK\Exceptions\ApiException;

class ContactService extends BaseService
{


    public function all()
    {
        $response = $this->client->get('/contacts');

        Log::info($response->getResponse());
        if ($response->isResponseSuccess()) {
            return $response->getResponseData()['data'];
        }
        throw new ApiException($response->getResponseData()['message']);

    }

}