PHP code example of vdhicts / hihaho-api-client

1. Go to this page and download the library: Download vdhicts/hihaho-api-client 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/ */

    

vdhicts / hihaho-api-client example snippets


// Initialize the configuration
$configuration = new \Vdhicts\HiHaHo\Configuration(
    ..
);

// Initialize the API
$api = new \Vdhicts\HiHaHo\HiHaHo($configuration);

// Get all videos
$response = $api->allVideos();

if ($response->ok()) {
    $response->json('data');
}

class Video extends HiHaHo 
{
    public function updateVideo(int $videoId): Response
    {
        return $this
            ->withToken($this->getAccessToken())
            ->put(sprintf('v2/video/%d', $videoId), [
                'status' => 0,
            ]);
    }    
}

if ($response->failed()) {
    var_dump($response->serverError());
}



return [
    'client_id' => env('HIHAHO_CLIENT_ID'),
    'client_secret' => env('HIHAHO_CLIENT_SECRET'),
    'username' => env('HIHAHO_USERNAME'),
    'password' => env('HIHAHO_PASSWORD'),
];

$configuration = new Configuration(
    config('hihaho.client_id'),
    config('hihaho.client_secret'),
    config('hihaho.username'),
    config('hihaho.password'),
);