PHP code example of tengs / douyin

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

    

tengs / douyin example snippets


$ php artisan vendor:publish --provider='Tengs\Douyin\ServiceProvider'
`
        $videoData = [
        'multipart' => [
                [
                    'Content-Disposition' => 'form-data',
                    'Content-Type' => 'video/mp4',
                    'name' => 'video',
                    'filename' => '1.mp4',
                    'contents' => file_get_contents(storage_path('1.mp4'))
                ]
            ]
        ];
        $video_id = '';
        $mediasHandler->setUrl('/video/upload/')->setBody($videoData)->Success(function ($data) use (&$video_id) {
                $video_id = $data['video']['video_id'];
            })->Error(function ($data) {
                //上传失败
            })->video($user);
        
        (new AuthHandler())->setUrl('/video/create/')
        ->setBody(['video_id' => $video_id])
        ->Success(function ($data) {
            //创建成功
        })->Error(function ($data) {
           //创建失败
        })->post($user);