Perl Youtube API:恢复上载*需要用户身份验证*

Perl Youtube API:恢复上载*需要用户身份验证*,perl,api,upload,youtube,Perl,Api,Upload,Youtube,我很累,三天没睡,我只做了一件事, 这是youtube上传的东西 这个非常简单的POST过程总是导致:“需要用户身份验证” 这就是我正在模仿的: POST /resumable/feeds/api/users/default/uploads HTTP/1.1 Host: uploads.gdata.youtube.com Authorization: Bearer ACCESS_TOKEN GData-Version: 2 X-GData-Key: key=adf15ee97731bca89da

我很累,三天没睡,我只做了一件事, 这是youtube上传的东西

这个非常简单的POST过程总是导致:“需要用户身份验证”

这就是我正在模仿的:

POST /resumable/feeds/api/users/default/uploads HTTP/1.1
Host: uploads.gdata.youtube.com
Authorization: Bearer ACCESS_TOKEN
GData-Version: 2
X-GData-Key: key=adf15ee97731bca89da876c...a8dc
Content-Length: 0
Slug: my_file.mp4
到目前为止,这就是我所做的:

#!/usr/bin/perl

use 5.010;
use strict;
use warnings;
use LWP::Simple;


    my $r = LWP::UserAgent->new()->post(
    "https://uploads.gdata.youtube.com/resumable/feeds/api/users/default/uploads",
        Content_Type => "application/atom+xml; charset=UTF-8",
        [
        'POST /resumable/feeds/api/users/default/uploads HTTP/1.1',
            Host            => "uploads.gdata.youtube.com",
           'Authentication' => "Bearer xxxxxx",
           'GData-Version' => "2",
           'X-GData-Key' => "key=xxxxx",
            Content_Length => "0",
           'Slug' => "C:/YouTube.wmv",
        ]
    );

    say $r->content;
我尝试了各种身份验证,Oath2,客户端登录, 我可以登录并获取访问令牌,问题是我无法上传

我喜欢perl,也讨厌youtube没有使用perl的支持库(有,但是它的非常过时的直接上传功能没有明确的文档记录,或者根本没有) 请帮帮我,我非常需要这个,我真的被困在这里了,我不知道问题是在我这方面,还是在youtube上


感谢您花时间阅读此文章,非常感谢。

在我看来,您调用
post()
时使用了错误的语法

问题并不十分清楚,但我认为您希望这样:

my $r = LWP::UserAgent->new()->post(
    'https://uploads.gdata.youtube.com/resumable/feeds/api/users/default/uploads',
    Content_Type => "application/atom+xml; charset=UTF-8",
    [
        Host            => "uploads.gdata.youtube.com",
       'Authentication' => "Bearer xxxxxx",
       'GData-Version'  => "2",
       'X-GData-Key'    => "key=xxxxx",
        Content_Length  => "0",
       'Slug'           => "C:/YouTube.wmv",
    ]
);

您不需要显式调用
POST()
的行。
post()
方法为您执行此操作。

您确定您的身份验证令牌有效吗?也就是说,上传以外的方法是否有效?此外,没有用于Perl的youtube库,因为没有人愿意编写和发布一个。上传你在github上正在处理的任何东西,然后就可以运行你的代码,看看哪里出了问题,然后把事情整理好。