我无法弄清楚,但是如果只有一个Google帐户登录浏览器,我的代码就可以正常工作,但是如果有一个以上的登录帐户,则可共享链接将显示错误403
function anyone($id, $token)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://www.googleapis.com/drive/v3/files/$id/permissions?key=$token");
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
"Content-type: application/json",
"Authorization: Bearer $token",
"{\"role\":\"reader\",\"type\":\"anyone\"}"
));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{\"role\":\"reader\",\"type\":\"anyone\"}");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
curl_close($ch);
return $result;
}
有人可以告诉我如何解决此问题吗?