Is it possible to use the Google Drive API with Spreadsheet API - php

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.

Related

how to passively access google apis using google client?

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.

QuickBooks Online v3 - REST API and the SDK

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

Get a list of files on google drive using PHP API

I am trying to use the API to Get a list of documents on a Google Drive then if I need to download a selected file that I query for. I cannot for the life of me figure out OAUTH and how to do this. I have a client ID , client secret key, but the documentation sucks.
I am trying to use :
https://developers.google.com/drive/v2/reference/files/list
Can you you use OAUTH with out having a use give permissions?
Can you you use OAUTH with out having a use give permissions?
No. That would defeat the purpose of OAuth.
My suggestion is start by ignoring Drive completely. Focus on understanding OAuth first.
Use the Oauth playground https://developers.google.com/oauthplayground/ and this page https://developers.google.com/accounts/docs/OAuth2 as your ONLY documentation. Everything you need to know is on those two links.
Once you have grasped Oauth, then use the Try It Now feature of https://developers.google.com/drive/v2/reference/files/list
to see how the Oauth token is used in your drive requests.

Obtaining a static auth token for Google APIs

I want to add a row to a Google Spreadsheet using PHP and the following library: https://github.com/asimlqt/php-google-spreadsheet-client which seems to be pretty simple.
However, I don't know how to obtain the required access token via the suggested Google's https://github.com/google/google-api-php-client library. I do not want my users to authenticate using OAuth, it is my server side, I just want to have a static access key somehow. It looks like the API has changed since the developer of the php-google-spreadsheet-client has used it?!
How to obtain a static access key from Google?
If not possible, how to obtain one without redirecting the user?
Is it possible to obtain such a key via https://github.com/google/google-api-php-client ?
For anybody interested: Google is coming up with a solution to the problem called "service accounts": https://code.google.com/p/google-api-php-client/wiki/OAuth2#Service_Accounts
Unfortunately it is not supported by many Google APIs yet. In the meantime one can run the "normal" OAuth authentication process once with the service user and cache the cookie for future use.
Alternative solution: use the old Zend framework and rely on Google API v1 instead of v3.

Youtube Analytics PHP cron

I want to start developing a tool that runs daily via cron for getting daily analytical data from one channel, or video, etc.. through the "Youtube Analytics API". And not what is the best way to approach it.
I have read the documentation of Google and and I have several questions:
I created the project in the console (https://code.google.com/apis/console/) but I doubt what kind of application I have to choose when I create a Client ID (Web Application, Service Account or Installed aplplication).
What PHP library use?
It's a very new API and not much information.
In the Google GData site there is a warning about that "Most newer Google APIs Google Data APIs are not Google Data APIs." and in the google-api-php-client, no examples of this API.
What is the best method for authentication in a cron?
As you can see I am very confuse, can someone help me, please?
Thank you.
1) It will be an installed application unless you will run it in a web server.
2) Use the official library, add the ytanalytics php library. Samples: https://github.com/youtube/yt-samples-php
3) You can do so by getting a refresh token from OAuth2 Playground and setting it in your youtube object.
Here it explains a little more.
And a step by step video.

Categories