我正在尝试使用 Youtube API 来自动允许用户通过基于浏览器的上传来上传视频到 Youtube。目前,我正在通过 PHP 进行 POST 请求,但没有curl
. 我无法访问curl
我正在使用的 Web 服务器。我到目前为止的代码是:
<?php
$theCode = $_GET['code'];
$urltopost = "https://accounts.google.com/o/oauth2/token";
$datatopost = http_build_query( array(
"code" => $theCode,
"client_id" => "312231647220287.apps.googleusercontent.com",
"client_secret" => "ULGrcIJOBfjka;dsfasdfyCd7Z5M",
"redirect_uri" => ".../youtubeTestCode/hello.php",
"grant_type" => "authorization_code"
));
$opts = array('http' =>
array(
'method => 'POST',
'header' => 'Content-type: application/x-www-form-urlencoded',
'header' => 'Host: accounts.google.com',
'content' => $datatopost
)
);
$context = stream_context_create($opts);
$result = file_get_contents($urltopost, false, $context);
?>
但是,当我尝试它时,我不断收到服务器错误。