drgc9632 2018-07-05 19:21
浏览 232

使用WebRTC并将视频上传到YouTube

I'm working on a project where I would like to use WebRTC to record a video from my PHP website and upload it to my YouTube channel. For the code below I am just trying to get an upload to work, as the video is saved on my server. I'm not clear on what kind of key or authorization I need to use. After reading and studying the documentation, I think I need to use a service account (key) to accomplish this? https://developers.google.com/api-client-library/php/auth/service-accounts

I do not want users to log in/authenticate a google account. I would like the upload to happen from my website to my YouTube channel.

I don't have access to install with composer, so I have uploaded the google-api-php-client (v2.2.2) folder on my server.

I haven't been able to find any current examples that are closer to what I need, so I'm trying to mashup these pieces:

Uploads to Drive: https://developers.google.com/api-client-library/php/guide/media_upload Uses the Service Account key(?): https://developers.google.com/api-client-library/php/auth/service-accounts Upload Video: https://developers.google.com/youtube/v3/code_samples/php#upload_a_video

I'm getting Any guidance is appreciated. I am receiving a "This page isn't working" HTTP ERROR 500

Here is what my code currently looks like:

<?php

    if (!file_exists('google-api-php-client/vendor/autoload.php')) {
    throw new \Exception('please run "composer require google/apiclient:~2.0" in "' . __DIR__ .'"');
    }

    require_once 'google-api-php-client/vendor/autoload.php';

    session_start();

    putenv('GOOGLE_APPLICATION_CREDENTIALS=I-Video/i-video-recording-0e9cbc2cad7a.json');
    $client = new Google_Client();
    $client->useApplicationDefaultCredentials();


    $file = new Google_Service_YouTube($client);
    $result = $service->files->insert($file, array(
    'data' => file_get_contents("data/1530103005236.webm"),
    'mimeType' => 'application/octet-stream',
    'uploadType' => 'media'
    ));
?>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
    • ¥85 maple软件,solve求反函数,出现rootof怎么办?
    • ¥15 求chat4.0解答一道线性规划题,用lingo编程运行,第一问要求写出数学模型和lingo语言编程模型,第二问第三问解答就行,我的ddl要到了谁来求了
    • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
    • ¥50 树莓派安卓APK系统签名
    • ¥15 maple软件,用solve求反函数出现rootof,怎么办?
    • ¥65 汇编语言除法溢出问题
    • ¥15 Visual Studio问题
    • ¥20 求一个html代码,有偿
    • ¥100 关于使用MATLAB中copularnd函数的问题