Is it possible to passively access google API using google api php client library? What I want to do is connect to google API by providing necessary credentials (not using oauth).
Basically, my oauth authentication will be in googleads php lib and want to access resources using php client lib. Or is there any way to accomplish this? Thanks.
EDIT:
What I really curious about for hours is integrating those two libraries (GoogleAds PHP Api and Google API Client API). The former uses pure Oauth and the latter uses 'Google_Client' implementation in accessing Google API.
Related
i am currently working on a Project with Firebase and i am trying to Implement the Firebase Cloud messaging service. I manage to make it work with a combination of PHP and Javascript (Javascript sends a Requiest to the server, where php makes a call to the Firebase API to send out a Notification).
The problem here is, that the code i use is for the old version, so its not using the HTTP v1.
When i looked at the docs on how to upgrade to the new version, i found out you need a short-lived OAuth 2.0 access token.
Thing is, the docs only show how you can get it via node.js, java, python, c# and go.
So my question is, is there a way to get the short-lived OAuth 2.0 access token with php or do i have to use something like node.js for it?
I'm not sure I fully understand your requirements, but if you want to send FCM notification from a PHP backend, I'd suggest checking out this (unofficial) Admin SDK for PHP (Disclaimer: I'm the creator of that library)
In its current state, you would need a Firebase Service Account (with Admin access) to be able to send notifications with it, but I'm currently working on a feature that will allow you to retrieve an OAuth access token for a given user (https://github.com/kreait/firebase-php/pull/390) in case you really need this.
I'd like to invite you to join https://discord.gg/nbgVfty (the Discord-Community around the PHP Admin SDK) to discuss your use case and process further.
Even if the SDK is not for you, looking through the code might could give you some ideas...
An alternative could be to use the Google PHP Api Client Services library, in which you can find a FirebaseCloudMessaging service.
I hope this helps!
I'm having a bit of trouble figuring out how to properly proceed making calls using the Intuit QuickBooks Online API v3. I've looked at the API Explorer, and from my understanding, I can send and receive JSON.
They also provide information about the base URL, the entity, etc: https://developer.intuit.com/docs/api/accounting/Customer
So I'm wondering, am I supposed to be using the QuickBooks SDK that they mention to download? https://developer.intuit.com/docs/0100_accounting
Or would I be able to utilize their API using something like cURL? I don't want to reinvent the wheel of course, but with all the information they provide and no reference to the SDK itself, that's where I started to get a little confused. They basically tell you how to make the calls, but don't reference the SDK in those documents.
Just to provide some extra information, I'm using PHP 5.5 and Laravel.
So I'm wondering, am I supposed to be using the QuickBooks SDK that they mention to download?
If you want to, sure.
Or would I be able to utilize their API using something like cURL?
Again, if you want to, sure. Just be aware that if you use cURL, you'll have to do some OAuth signing of your requests (see the OAuth spec) or find an OAuth lib too.
Here's another open-source alternative if you need something with more examples (disclaimer: I'm the author):
https://github.com/consolibyte/quickbooks-php
Examples:
https://github.com/consolibyte/quickbooks-php/tree/master/docs/partner_platform/example_app_ipp_v3
The documentation for accessing the Quickbooks Online API seems to revolve around creating applications for public use. I'm only interested in developing an app to access my very own Quickbooks file. However, I'm having difficulty authenticating.
I successfully obtain all the necessary codes and can run API calls in the API playground. My preference would be not to use any libraries (including the Quickbooks PHP library as it does not support JSON).
I have spent hours searching but I do not know how to 'sign' the various secrets and codes to obtain the Oauth token needed. Does anyone have working PHP code?
I'd like to simply be able to input in the values and make the API calls via curl.
I have spent hours searching but I do not know how to 'sign' the various secrets and codes to obtain the Oauth token needed.
You sign the code using OAuth. This is a well documented authentication method, with many implementations.
Does anyone have working PHP code?
Sure:
https://github.com/consolibyte/quickbooks-php/blob/master/QuickBooks/IPP/OAuth.php#L77
https://code.google.com/p/oauth-php/
https://php.net/manual/en/book.oauth.php
https://pecl.php.net/package/oauth
https://github.com/Lusitanian/PHPoAuthLib
My preference would be not to use any libraries
OAuth is not a trivial authentication method. You should use a library to sign your requests -- it will save you a lot of time vs. implementing your own OAuth signatures.
Is there a way to tie Spreadsheets API in with Drive API? By which I mean, if I have a file ID from Google Drive can I then switch to the Spreadsheets API using the same ID and the same oAuth credentials?
I am using php and there is precious little resources especialy for the spreadsheet api - I'm suprised there's so little around.
You additionally need to grant permission for user for the following scope:
https://spreadsheets.google.com/feeds
The resources IDs are identical on both APIs. My spreadsheet file on Drive, identified with 0AifSjdPVs9MZdE10eXZTVHVneW9aYjJGVFMxV0VYUEE is accessible on Spreadsheets API with the same ID:
https://spreadsheets.google.com/feeds/spreadsheets/0AifSjdPVs9MZdE10eXZTVHVneW9aYjJGVFMxV0VYUEE
Note: I made the spreadsheet publicly readable, you can try out Spreadsheets API backends with this file.
Here's the solution I came up with:
Get both the google-api-php-client library AND the Zend GData
library (Zend Framework 1.2, with dependencies).
Use the Google API
Google_Oauth2Service class to handle login and authentication. Be
sure that your "scopes" includes https://www.googleapis.com/auth/drive AND
https://spreadsheets.google.com/feeds .
Once the oauth2 handshake is finished (the details of which you can find documentation for), you have a token, which is a json-encoded string. Turn this into a PHP object: $tok = json_decode([token string])
And here's the magic: just give the access piece of the token to the Zend library
$authsub = Zend_Gdata_AuthSub::getHttpClient($tok->access_token);
$spreadsheet_service = new Zend_Gdata_Spreadsheets($authsub);
Now you can use your spreadsheet service as documented in the Zend library. Works great.
Is there a way to active a Google Api service in php without going through the Google API Console website?
This depends on which API you want to use. A few APIs, e.g. the Google Static Maps API do not require you to register as an application. Most APIs, especially the ones that access some user's data, however require you to setup an API project with Google's APIs Console, so Google knows that it is your application that accesses its API.