【问题标题】:Google Client API is showing ErrorGoogle 客户端 API 显示错误
【发布时间】:2016-03-31 12:11:04
【问题描述】:

我正在尝试将 google 客户端 api 集成到我的 codeigniter 项目中,并且我已将 google 客户端 api 库放在我的第三方文件夹中。然后制作了一个名为 Google.php 的库,代码如下:

<?php
if (!defined('BASEPATH'))
    exit('No direct script access allowed');
set_include_path(APPPATH . 'third_party/' . PATH_SEPARATOR . get_include_path());
require_once APPPATH . 'third_party/Google/Client.php';

class Google extends Google_Client {
    function __construct($params = array()) {
        parent::__construct();
    }
}
?>

然后我将这个库包含在我的主控制器中并尝试访问它,

<?php defined('BASEPATH') OR exit('No direct script access allowed');

class main extends CI_Controller {   
     function __construct() {
            parent::__construct();
            $this->load->library('google');
     }  
     public function index()    {       
            echo $this->google->getLibraryVersion();
     }
}

但是当我尝试这个谷歌客户端库时,会显示下面给出的这个错误。 Google Client.php 在此行显示第一个错误

/** @var array $scopes */
  // Scopes requested by the client
  protected $requestedScopes = [];

【问题讨论】:

  • 我没有更改客户端库中的任何内容。如果我按照您的建议使用简单数组,那么它会在这些行上显示错误。 $this->config = Collection::fromConfig( $config, [ 'application_name' => '',
  • 你的php版本是多少?
  • 我认为是 5.3.13

标签: php codeigniter youtube-api google-client youtube-data-api


【解决方案1】:

问题是你只能在php 5.4之后使用短数组语法[]。您使用的库与 php 5.4+ 兼容。 文档是here.

从 PHP 5.4 开始,您还可以使用短数组语法,它替换 array() 与 []。

您需要升级您的 php 版本或使用其他支持旧版本 php 的库。

【讨论】:

    猜你喜欢
    • 2013-01-19
    • 1970-01-01
    • 2015-10-31
    • 1970-01-01
    • 2012-12-01
    • 2021-12-24
    • 2015-08-14
    • 2014-06-18
    • 2017-07-28
    相关资源
    最近更新 更多