为什么 Google API PHP 在 WEB 服务器上不工作
Why Google API PHP not working on WEB SERVER
你们知道为什么 google api 将我的网站放在网络服务器上时无法正常工作的原因(加油爸爸)以及如何修复它?
但它在本地主机上运行良好?
include 'system/includes/connection.php';
require __DIR__ . '/googleApi/vendor/autoload.php';
$client = new \Google_Client();
$client->setApplicationName('Google Sheets and PHP');
$client->setScopes([\Google_Service_Sheets::SPREADSHEETS]);
$client->setAccessType('offline');
$client->setAuthConfig('client_credentials.json');
$service = new Google_Service_Sheets($client);
这是我的错误日志中显示的错误。
[08-Aug-2020 01:38:38 Asia/Manila] PHP 解析错误:语法错误,意外的 ':',期待 '{' in/home/y2efod66lc11/public_html/googleApi/vendor/guzzlehttp/guzzle/src/functions.php 在线14
里面是这样的function.php
https://hasteb.in/egehofos.xml
您必须将 PHP 版本升级到 7.0 或更高版本,那时才添加 return 类型。
但是请注意,您应该使用 PHP 7.3 或更高版本,因为不再支持 7.1 和更低版本,并且 7.2 将于今年 11 月底结束生命周期。
https://www.php.net/supported-versions.php
短
正如我在评论中提到的和@Thor 也指出的那样,您需要将主机上的 PHP 版本至少更改为 7.0
,而不是最高版本。在他们的文档中检查 Google 的 API 要求,哪个 PHP 版本是最低的。
详情
Argument type declarations and return type declarations were introduced (finally!) in PHP ver. 7.0
see what else.
所以这是 PHP 7.x
的有效代码
function describe_type($input): string
{
return Utils::describeType($input);
}
function headers_from_lines(iterable $lines): array
{
return Utils::headersFromLines($lines);
}
因为这个 将 在 PHP 5.x
有效
function describe_type($input)
{
return Utils::describeType($input);
}
function headers_from_lines($lines)
{
return Utils::headersFromLines($lines);
}
找不同。
你们知道为什么 google api 将我的网站放在网络服务器上时无法正常工作的原因(加油爸爸)以及如何修复它? 但它在本地主机上运行良好?
include 'system/includes/connection.php';
require __DIR__ . '/googleApi/vendor/autoload.php';
$client = new \Google_Client();
$client->setApplicationName('Google Sheets and PHP');
$client->setScopes([\Google_Service_Sheets::SPREADSHEETS]);
$client->setAccessType('offline');
$client->setAuthConfig('client_credentials.json');
$service = new Google_Service_Sheets($client);
这是我的错误日志中显示的错误。 [08-Aug-2020 01:38:38 Asia/Manila] PHP 解析错误:语法错误,意外的 ':',期待 '{' in/home/y2efod66lc11/public_html/googleApi/vendor/guzzlehttp/guzzle/src/functions.php 在线14
里面是这样的function.php https://hasteb.in/egehofos.xml
您必须将 PHP 版本升级到 7.0 或更高版本,那时才添加 return 类型。
但是请注意,您应该使用 PHP 7.3 或更高版本,因为不再支持 7.1 和更低版本,并且 7.2 将于今年 11 月底结束生命周期。 https://www.php.net/supported-versions.php
短
正如我在评论中提到的和@Thor 也指出的那样,您需要将主机上的 PHP 版本至少更改为 7.0
,而不是最高版本。在他们的文档中检查 Google 的 API 要求,哪个 PHP 版本是最低的。
详情
Argument type declarations and return type declarations were introduced (finally!) in PHP ver. 7.0
see what else.
所以这是 PHP 7.x
function describe_type($input): string
{
return Utils::describeType($input);
}
function headers_from_lines(iterable $lines): array
{
return Utils::headersFromLines($lines);
}
因为这个 将 在 PHP 5.x
function describe_type($input)
{
return Utils::describeType($input);
}
function headers_from_lines($lines)
{
return Utils::headersFromLines($lines);
}
找不同。