Google-api-php-client: Install without composer

Created on 6 Feb 2018  路  10Comments  路  Source: googleapis/google-api-php-client

Hi i would like to ask can i install without using composer? because i direct download from here and upload to my ftp i cant direct call the autoload.

Thank you

question

All 10 comments

Yeah I always have to look it up too. -L stands for location as in the follow the Location field in the response header.
curl -OL https://github.com/google/google-api-php-client/releases/download/v2.2.1/google-api-php-client-2.2.1.zip

I have download the google-api-php-client folder and upload to my ftp via filezilla, then i using require_once ('/google-api-php-client-2.2.1/vendor/autoload.php' ); to call the folder but it show blank page to me, its possible the path problem or must install using composer?

The v1-master branch is for use without composer. Your going to have to see what that does and load things accordingly.

Try checking the examples in that branch here if you have any questions put a question up on stack overflow i should spot it. Tag it google-api-php-clinet

@LindaLawton i find out the problem why i can direct call the php file by download from here, below are the autoload.php code:
`

// autoload.php @generated by Composer

require_once __DIR__ . '/composer/autoload_real.php';

return ComposerAutoloaderInit4bcd804d35cc650d1fb52c557725a2a1::getLoader();
`

how can i got the autoload.php correctly without generate using composer?

session_start();
include_once "templates/base.php";

require_once realpath(dirname(__FILE__) . '/../src/Google/autoload.php');

Should work even without using composer the issue is where you have put your files. When you download the library the paths have to be correct or your not going to be able to find autoload.php.

@LindaLawton i try the code you provide, i cant find the base.php file, i download the google api php client from here https://github.com/google/google-api-php-client/releases

I have modify the code it into
session_start(); require_once 'google-api-php-client-2.2.1/src/Google/autoload.php');

its still cant work. Below are my autoload.php code in the Google folder
`

/**

  • THIS FILE IS FOR BACKWARDS COMPATIBLITY ONLY
    *
  • If you were not already including this file in your project, please ignore it
    */

$file = __DIR__ . '/../../vendor/autoload.php';

if (!file_exists($file)) {
$exception = 'This library must be installed via composer or by downloading the full package.';
$exception .= ' See the instructions at https://github.com/google/google-api-php-client#installation.';
throw new Exception($exception);
}

$error = 'google-api-php-client's autoloader was moved to vendor/autoload.php in 2.0.0. This ';
$error .= 'redirect will be removed in 2.1. Please adjust your code to use the new location.';
trigger_error($error, E_USER_DEPRECATED);

require_once $file;`

Thank you

@LindaLawton Below are my full code
`

session_start();
require_once 'google-api-php-client-2.2.1/src/Google/autoload.php');

$accessToken = initializeAnalytics();

function initializeAnalytics()
{
$KEY_FILE_LOCATION ='client_secret_917950001739-6vodhfsbpmipoh29fl3f1pkqmo7u9dhv.apps.googleusercontent.com.json';

$client = new Google_Client();
$client -> setApplicationName("testing");
$client -> setAuthConfig($KEY_FILE_LOCATION);
$client -> setScopes(['https://www.googleapis.com/auth/analytics.readonly']);
$client -> refreshTokenWithAssertion();
$client -> setAccessType("offline");
$client -> setRedirectUri('http://' . $_SERVER['HTTP_HOST'] . '/testing-embed.php');
$token = $client->getAccessToken();
$accessToken = $token['access_token'];

return $accessToken;

}

echo $accessToken;

?>





`

I think you should post a question on stackoverflow this is not an issue with the client library but an issue with your ability to use the tutorials provided. You should follow with tutorial Hello analytics

If you cant use composer you simply need to download this branch v1-master and make sure the src/Google directory is in your directory with your file.

ok, thanks for your help!

Looks like this issue can be closed. Thanks, @LindaLawton

Was this page helpful?
0 / 5 - 0 ratings

Related issues

whatido1 picture whatido1  路  3Comments

slaFFik picture slaFFik  路  5Comments

upendtu picture upendtu  路  4Comments

delmohf picture delmohf  路  3Comments

AlexandreGerault picture AlexandreGerault  路  5Comments