首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >消息和视频分享youtube php

消息和视频分享youtube php
EN

Stack Overflow用户
提问于 2014-01-20 19:18:03
回答 1查看 124关注 0票数 0

我想获得用户的youtube收件箱,并发送视频消息。下面是我用来检索收件箱的代码。收件箱来了,显示用户XXXX的收件箱,但收件箱是空的,没有消息来。而我的收件箱里有四条视频信息。

代码语言:javascript
复制
$developer_key='REPLACE_ME';
$client_id= 'REPLACE_ME';
$client_secret='REPLACE_ME';

// error checking; user might have denied access
if (isset($_GET['error'])) {
    if ($_GET['error'] == 'access_denied') {
        echo('You have denied access. Click <a href="'. $_SERVER["SCRIPT_NAME"] .'">here</a> to retry&hellip;');
    } else {
        echo("An error has occurred: ". $_GET['error']);
    }
    exit;
}

// Step 1: redirect to google account login if necessary
if(!isset($_GET['code']) || $_GET['code'] === '') { 
    Header('Location: https://accounts.google.com/o/oauth2/auth?client_id='. $client_id .
            '&redirect_uri=http://localhost:8080/Test/sendMessage.php' .
            '&scope=https://gdata.youtube.com&response_type=code&access_type=offline',
        true, 307);
    exit;
}
$authorization_code= $_GET['code'];

// Step 2: use authorization code to get access token
$url = "https://accounts.google.com/o/oauth2/token";
$message_post= 'code='. $authorization_code .
        '&client_id='. $client_id . 
        '&client_secret='. $client_secret .
        '&redirect_uri=http://localhost:8080/Test/sendMessage.php' .
        '&grant_type=authorization_code';


$ch = curl_init($url);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $message_post);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
echo "<pre>";
echo "<br><br> message_post : ";
print_r($result);
if ($cur_error= curl_error($ch)) {
    echo($cur_error);
    curl_close($ch);
    exit;
}
curl_close($ch);

$jsonArray= json_decode($result, true);

if ($jsonArray === null) {
    echo("Could not decode JSON.");
    exit;
}

if (isset($jsonArray['error'])) {
    echo("An error has occurred: ". $jsonArray['error']);
    exit;
}

if (!isset($jsonArray['access_token'])) {
    echo("Access token not found.");
    exit;
}


//The user's authentication token
$access_token= $jsonArray['access_token'];
$title ='krishna'; //The title of the caption track
$lang = 'en'; //The languageof the caption track
//$transcript = $_REQUEST['transcript']; //The caption file data
$inboxUrl ='https://gdata.youtube.com/feeds/api/users/default/inbox?alt=json&&key=AIzaSyBeh0Aevex7q3iRIY5bV3N9gx0WAkNBMi4&access_token=' . $access_token;
echo $inboxUrl . "<br />";
$homepage = file_get_contents($inboxUrl);
echo "file content : <pre>";
print_r($homepage);
EN

回答 1

Stack Overflow用户

发布于 2014-01-20 19:42:49

YouTube的视频回复功能已经停用,如本announcement所述。虽然现有视频响应仍然可用,但YouTube不再支持检索视频的视频响应列表、上载新的视频响应或删除视频响应的功能,但您可以删除视频响应中使用的视频。因此,API中也不再支持这些函数。

https://developers.google.com/youtube/2.0/developers_guide_protocol_video_responses

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21232599

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档