Hi i am trying to connect to google api so i can get my stats via the browser. I dont want to use composer. How can i do this?
Here is what i have so far.
i downloaded and installed the following dependents
needed libs
Only 1 file included for the grpc library
https://github.com/protocolbuffers/protobuf
https://github.com/googleapis/php-analytics-data
https://github.com/googleapis/gax-php
https://github.com/googleapis/google-auth-library-php
https://github.com/grpc/grpc
I have replaced this code for current code, i want to start over from scratch and go one step at a time. First i will get the dependencies loaded and then i will do the client credentials, and then ill get the property data.
So lets get the dependencies first.
//init arrays
$library_array = [];
/*
******************************
PRE LOADING LIBRARY FILES
******************************
*/
//preload lib files and MUST BE IN THIS ORDER
//protobuf-main in this order
require_once('libraries/protobuf-main/php/src/Google/Protobuf/Internal/Message.php');
require_once('libraries/protobuf-main/php/src/Google/Protobuf/Internal/HasPublicDescriptorTrait.php');
//gax-php-main in this order
require_once('libraries/gax-php-main/src/ValidationTrait.php');
require_once('libraries/gax-php-main/src/PollingTrait.php');
require_once('libraries/gax-php-main/src/ResourceTemplate/ResourceTemplateInterface.php');
require_once('libraries/gax-php-main/src/ResourceTemplate/AbsoluteResourceTemplate.php');
require_once('libraries/gax-php-main/src/ResourceTemplate/Parser.php');
require_once('libraries/gax-php-main/src/ResourceTemplate/RelativeResourceTemplate.php');
require_once('libraries/gax-php-main/src/ResourceTemplate/Segment.php');
require_once('libraries/gax-php-main/src/AgentHeader.php');
require_once('libraries/gax-php-main/src/ApiException.php');
require_once('libraries/gax-php-main/src/ApiStatus.php');
require_once('libraries/gax-php-main/src/ArrayTrait.php');
require_once('libraries/gax-php-main/src/BidiStream.php');
require_once('libraries/gax-php-main/src/Call.php');
require_once('libraries/gax-php-main/src/ClientStream.php');
require_once('libraries/gax-php-main/src/CredentialsWrapper.php');
require_once('libraries/gax-php-main/src/FixedSizeCollection.php');
require_once('libraries/gax-php-main/src/GPBLabel.php');
require_once('libraries/gax-php-main/src/GPBType.php');
require_once('libraries/gax-php-main/src/GrpcSupportTrait.php');
require_once('libraries/gax-php-main/src/OperationResponse.php');
require_once('libraries/gax-php-main/src/Page.php');
require_once('libraries/gax-php-main/src/PageStreamingDescriptor.php');
require_once('libraries/gax-php-main/src/PagedListResponse.php');
require_once('libraries/gax-php-main/src/PathTemplate.php');
require_once('libraries/gax-php-main/src/UriTrait.php');
require_once('libraries/gax-php-main/src/RequestBuilder.php');
require_once('libraries/gax-php-main/src/RequestParamsHeaderDescriptor.php');
require_once('libraries/gax-php-main/src/ResourceHelperTrait.php');
require_once('libraries/gax-php-main/src/RetrySettings.php');
//this is the only grpc file that i required from the library
require_once('libraries/grpc-master/src/php/lib/Grpc/BaseStub.php');
//finish gax files in this order
require_once('libraries/gax-php-main/src/ServerStream.php');
require_once('libraries/gax-php-main/src/ServerStreamingCallInterface.php');
require_once('libraries/gax-php-main/src/ServiceAddressTrait.php');
require_once('libraries/gax-php-main/src/ValidationException.php');
require_once('libraries/gax-php-main/src/Version.php');
require_once('libraries/gax-php-main/src/GapicClientTrait.php');
//preload google auth files in this order
require_once('libraries/google-auth-library-php-main/src/FetchAuthTokenInterface.php');//must be before the other auth library files
require_once('libraries/google-auth-library-php-main/src/UpdateMetadataInterface.php');//must be before the other auth library files
require_once('libraries/google-auth-library-php-main/src/GetQuotaProjectInterface.php');
require_once('libraries/google-auth-library-php-main/src/SignBlobInterface.php');
require_once('libraries/google-auth-library-php-main/src/ProjectIdProviderInterface.php');
/*
*************************************
NORMAL LOADING REST OF LIBRARY FILES
*************************************
*/
//must be loaded in this order
//protobuf needs to be loaded first before analytics
$library_array = [
'libraries/protobuf-main/php/src/Google/Protobuf/Internal/',
'libraries/google-auth-library-php-main/src/',
'libraries/php-analytics-data-master/src/V1beta/Gapic/',
'libraries/php-analytics-data-master/src/V1beta/'
];
foreach($library_array as $lkey => $lval)
{
foreach (glob($lval."*.php") as $lib_filename)
{
require_once($lib_filename);
//testing
//echo "<pre>";
//echo "require_once('". $lib_filename ."');";
//echo "<br>";
}
}//close foreach library array
/*
*************************************
ALL DEPENDENTS LOADED
LETS SET OUR CREDENTIAL AND
OTHER VARS
*************************************
*/
//and then we write a cURL or other class to connect because we cant use
//class BetaAnalyticsDataClient as the instructions say here
// https://developers.google.com/analytics/devguides/reporting/data/v1/quickstart-client-libraries
echo "<pre>";
echo "All dependents loaded and now write a connect process";
exit;
So how do i verify credentials and connect for google api data now that i cant use the google class BetaAnalyticsDataClient as it requires guzzle which i dont want to use?
Any suggestions would be great thanks 🙂
=========== new code for connection =============
My strong advice here is to watch Linda’s Video here, then you will understand how to use googles oauth2 for authorization and more.
2
Answers
The best answer i can give here is this... I strongly advise to watch Linda's Video here, then you will understand how to use googles oauth2 for authorization and more.
https://www.youtube.com/watch?v=hBC_tVJIx5w
Thank you Linda, you have been awesome.... I got step 1 working and received the permission block, i will be working on step 2.
You are using the wrong client library to start with you want the googleapis/php-analytics-data
TBH I have never tried to install it without composer in theory you should be able to grab the V1beta directory and just use that but I havent tried.