K. Uzair
K. Uzair

Reputation: 303

Google Client API is showing Error

I am trying to integrate google client api in my codeigniter project and i have put google client api library in my thirdparty folder. And then made a library named Google.php Code is given below:

<?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();
    }
}
?>

And then i include this library in my main controller and tried to access it,

<?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();
     }
}

but when i tried this Google Client Library shows this error given below. enter image description here Google Client.php is showing first error on this line

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

Upvotes: 2

Views: 320

Answers (1)

mim.
mim.

Reputation: 677

The problem is you can only use short array syntax [] after php 5.4. The library you use is compatible with php 5.4+ . Documentation is here.

As of PHP 5.4 you can also use the short array syntax, which replaces array() with [].

You need to upgrade your php version or use another library which supports older versions of php.

Upvotes: 2

Related Questions