I've installed Google API with composer and get authenticated. There are no problems about that but when i started to look at to examples from the web site and downloaded files they are really different.
In developer web site example codes starts with like:
// Include the initialization file
require_once dirname(dirname(__FILE__)) . '/init.php';
require_once UTIL_PATH . '/MapUtils.php';
But in downloaded files they start with like:
namespace Google\AdsApi\Examples\AdWords\v201609\Optimization;
require 'vendor/autoload.php';
use Google\AdsApi\AdWords\AdWordsServices;
use Google\AdsApi\AdWords\AdWordsSession;
use Google\AdsApi\AdWords\AdWordsSessionBuilder;
use Google\AdsApi\AdWords\v201609\cm\Keyword;
use Google\AdsApi\AdWords\v201609\cm\KeywordMatchType;
use Google\AdsApi\AdWords\v201609\cm\Language;
use Google\AdsApi\AdWords\v201609\cm\Location;
...
There are no "init.php" in latest version (201609) anymore so i think on web site the examples are outdated. Examples that come with downloaded files working good but when i try to learn something different there are no online examples from developers site.
I think I am missing something but don't know what is that is. Can anyone explain me why those two examples are different? Thanks.
The documentation has just been updated. Please have a look at that page again.
Sorry for this confusion.
In the future, I highly recommend to post you questions either in our github repo's issues (if it's related to PHP client library only) or our AdWords API forum instead, as we're monitoring these two sites regularly and you could get answers much faster. :)
Best,
Thanet
Related
I'm new to app engine and trying create a php app from a sample code.
Can anyone please tell me what is the use of
require_once DIR . '/vendor/autoload.php';
Is this set of libraries we need to download?
I'm developing/test locally and deploying in to gcloud project using 'gcloud app deploy'
I can use
use google\appengine\api\users\User;
but I cannot use
use google\cloud\storage\StorageClient;
Fatal error: Class 'google\cloud\storage\StorageClient' not found in C:\Users..
Is there a component to install for cloud storage?
Thanks
Thank you for your advice.
ACtually even after deploying project in to my google project I get the
same issue.
That's why I thought it's something to do with gcloud app engine setting.
Because according to my understanding in google app engine all the
libraries are available by default. Aren't it?
This is my project and I get the same error.
https://assignment2-s3682248.appspot.com/
https://rb.tc/4YY3B#https://assignment2-s3682248.appspot.com/
Chears
Sam
On Fri, Sep 27, 2019 at 4:27 AM 'George (Cloud Platform Support)' via
Google App Engine wrote:
As PHP scripts run relative to the current path, not to the path of
script itself, you can use DIR to change this behavior, so that include
refers to the script's own path, as a result.
StorageClient not found error is likely due to the absence of Cloud
Storage Client Libraries
https://cloud.google.com/storage/docs/reference/libraries, which you'll
have to install.
This discussion group is oriented more towards general opinions, trends,
and issues of general nature touching the app engine. For coding in PHP,
and program architecture, as well as importing Cloud Storage Client
Libraries, you may be better served in dedicated forums such as
stackoverflow, where experienced programmers are within reach and ready to
help.
I'm really not sure if your question has already been answered (since I see you posted an answer that a GCP support agent gave you) but you didn't accept it.
If you are new with App Engine/PHP I would recommend to follow the documentation's quickstart to get a simple project up and running and then you can start modifying it accordingly to your requirements.
From the questions I could find on your post, how to use the "autoload" of composer with DIR and how to use the Cloud Storage lib in your app. I recommend to carefully read the documentation I have referenced (the three are from the same documentation but on specific parts) which describes the step by step on how to build your application.
I want to be able to use the Google API with PHP, but I don't want to have to include all 23MB and 8,000+ files. I only really need the Sheets and Drive functionality (for now), but autoload seems to insist I include everything.
Because of what I'm using it for, running Composer I think isn't feasible and I've never managed to get composer working with XAMPP anyway.
Help appreciated.
Check your directory structure you should have something like "Google/Service" look inside. There is a class for each of the Google APIs. Unless you are using every single one of the Google APIs you dont need all of these files. You can remove all but the one API you are going to be using.
That is the extent of what files you can safely remove everything else is needed.
I made a WP plugin which depends on the Youtube API. So, to do it well, I use Google API PHP client.
My issue is quite simple: the Google API PHP client is huge (more than 12 000 files), including clients for all Google services, when I just need to use Youtube service. So I'm not confortable committing all those files to the WP plugins repo when most of them are useless in my case.
So, right now, my composer.json looks like this:
{
"require": {
"google/apiclient": "^2.0"
}
}
Any way to use only the Youtube API client (using composer if it's possible)?
This is not for the feign of heart but it is doable.
Go to this branch of the repo https://github.com/google/google-api-php-client/tree/v1-master
Grab the full src/Google directory you will need all of that.
In the src/Google/Service directory is the stuff for all the different APIs. Remove everything except for YouTube.
cross your fingers it should work.
This wont remove all 12000 files but it should give you just what you absolutely need. I used to do this but its been a few years.
Unfortunately, I don't think this is possible without manually including the relevant files in your project (which is a really bad idea).
The reason why its impossible, is because Google places all service APIs for the PHP library in a single GitHub repository found here:
https://github.com/google/google-api-php-client-services
If Google does split them into multiple repositories, then it could be possible to include a single repo.
For now, though, all services are under one composer project and one repo. Maybe its worth making a GitHub issue to ask Google about this?
Hi I am really struggling with this one.
I am developing with Google Analytics and Google Adwords; and I am using two separate Oauth libraries in the API Helper Libraries that are written by Google. One is an extension (oauth.so) for Adwords and the other is just a PHP class for Analytics.
When I alter my php.ini file to load the extension, my Analytics OAuth breaks. I think it maybe a conflict of the class names? I have tried changing the name, but haven't had any luck. I had thought that I came up with a solution: Using the dl() function to dynamically load the oauth.so extension on just the Adwords related pages (they are separate scripts):
dl('oauth.so');
Which works great on the command line! But it doesn't work in the browser. I refuse to believe that nobody has come across this issue before. I know that loading the extension from php.ini works in the browser, it just disables the Analytics class. Any one with experience with this, I'd love to hear your input, if you have any suggestions please feel free!
Thank you
The AdWords API PHP client library has been updated to allow for different OAuth libraries:
http://code.google.com/p/google-api-adwords-php/source/detail?r=178
You could even write your own OAuthHandler class that utilized the existing OAuth library that the Analytics library uses.
It's been removed from some SAPI's, either switch to CGI for the webserver (brr), or try to fix the problem with your Analytics PHP class.
I have tried googling a lot but couldn't find a library which can provide me single-sign on feature for my website.
I am looking for similar script like stackoverflow is using for facebook, twitter, google, openid etc...
I have tried hybridauth, http://hybridauth.sourceforge.net/ but it's not working for me.
Could you guys please suggest me other alternatives?
I've seen several website using this library : http://www.janrain.com/products/engage
(formerly https://rpxnow.com/)
I have not personally tried..
Why not OpenID itself? I heard good thing about it, and the same, as you specified, SO use it. There's an OpenID website that keep track of all libraries found from official OpenID team of third-part solution that you can find here: http://openid.net/developers/libraries/.
Choose what suits best your needs.
Notice that they warn you:
We have setup a code repository for gathering libraries and other supporting examples. While several of these libraries have been tested, they are maintained by members of the OpenID community and are not necessarily known to work.