Google drive API, Google Drive PHP API

Diving in Google Drive APIs

Hello developers! I know this is something other than WordPress at WPBrigade but we can’t forget the importance and usage of Google Apps in the WordPress community.

Analytify is one kind of WordPress plugin that uses Google Analytics APIs heavily and simplifying the life of data lovers in WordPress. It displays all the actionable Analytics in one dashboard and shows you Analytics, page by page.

So, I have decided to start a series of blog posts on Google Drive APIs in which I will walk you through some interesting things about the Drive SDK. I will take you from the scratch and reach a point where you will have a good knowledge of Drive SDK and can use it in your future web apps. If this series helps you in any way, shoot it out and Share it with your friends and there is no reason not to take interest in learning Google Drive APIs as it’s usage is totally free.

When I was living my life as a Google Student Ambassador in 2013-2014 I spread the goodness of Google Drive in many of my events. I fell in love with Google Drive and using it since then.

If you want to know more about (after watching the above video) Google Drive. I recommend watching a couple of these videos on youtube.

Google Drive API Overview

I assume you have a beginner level of knowledge of any programming language. Google Drive platform provides client libraries of all the popular languages like .Net, PHP, JS, Node.js, iOS, and Android. However, I will use the PHP client library in this course as I am a PHP guy and building Web Apps in PHP for years. We have documentation of Drive SDK which helps us develop apps that integrate with Drive. You know Google Drive is a platform where you can only upload and download files and thinks that it is only for storage?  Well!  After finishing this course, you will be amazed that you can even make money from these apps.

Ok Ok, be patient, Let’s start our Journey !!

Installation

Before you install the PHP Client library, you should confirm that running the PHP version on your machine is greater or equal to 5.3.2 with JSON extension enabled. Normally, the JSON extension is already enabled in packages.

Download the latest (zip file) release from the Google Drive github repository and unzip it on your machine. I recommend using git version control to manage your codeIf you are familiar with git then use the below command and clone the master branch like this

git clone https://github.com/google/google-api-php-client/

So, you got the library files on your machine. When you unzip or clone the PHP client library, It will be a folder google-API-PHP-client  and the file structure will be 

Diving in Google Drive APIs

 

If you open /examples/ folder in your browser and try to run any example, you will see a warning message.

Warning: You need to set Client ID, Client Secret and Redirect URI from the Google API console

Create a Project in Google Console

Yes, it is necessary to create a project in Google console and set Client ID, Client Secret and Redirect URI in your code. I have written a detailed tutorial here. You just need to Enable the Drive API instead of Analytics API as you are going to use this project for Drive Apps.

So, there were 2 steps today.

  1. Installation
  2. Create a Project in Google Console.

That is it  for today. In the next part, we will start writing a script and use the settings of the Google Project console in our code.


 

Resources

Save to Drive button

Google Drive Client libraries

Google Drive Stackoverflow Group

Sample code at github 

G+ Community

Blog on Google Apps

2 thoughts on “Diving in Google Drive APIs”

  1. Can anybody explain please: Why is it able in Google API to create many folders (different IDs) with same name ? WHY???

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.