PHP Quick Start

This project shows you how to implement a simple piece of Glassware that demos the major functionality of the Google Mirror API.

To see a fully-working demo of the quick start project, go to https://glass-python-starter-demo.appspot.com. Otherwise, read on to see how to deploy your own version.

Download on GitHub


  • PHP 5.3.x or higher
  • A web server - You need a place to host your files. Apache httpd and nginx work great.
  • To use subscriptions you also need an Internet accessible hosting environment with a valid SSL certificate signed by a trusted certificate authority.

Creating a Google APIs Console project

Next, enable access to the Google Mirror API:

  1. Go to the Google APIs console and create a new API project.
  2. Click Services and enable the Google Mirror API for your new project. the Google Mirror API on the Google API Console
  3. Click API Access and create an OAuth 2.0 client ID for a web application. the API Access section of the Google API console
  4. Specify the product name and icon for your Glassware. These fields appear on the OAuth grant screen presented to your users. specifying brand information
  5. Select Web application and specify any value for the hostname, such as localhost selecting application type
  6. Click Edit settings... for the client ID to specify redirect URIs. Specify the callback URLs for your local development web server, for example http://localhost:8080/oauth2callback, and for your deployed web server, for example https://example.com/oauth2callback. the Google API console configuration panel for redirect URIs
  7. Make note of the client ID and secret from the Google APIs Console. You'll need it to configure the quick start project. the client id and secret on the Google API console

Configuring the project

Enter your client ID, secret, simple API key, a base URL and a location where a SQLite database can be created in config.php:

$api_client_id = "1234.apps.googleusercontent.com";
$api_client_secret = "ITS_A_SECRET_TO_EVERYBODY";
$api_simple_key = "AIzaSyCCbHcqDeb0oycQ9niV8P3n0F0qM";

$base_url = "http://example.com/starter-project";

$sqlite_database = "/tmp/database.sqlite";

Deploying the project

Deploy the Quick Start project to your host server:

  1. Copy the PHP Quick Start directory to the documents directory of your HTTP web server.
  2. Depending on your system configuration, you may need to pre-create a writable file for the SQLite database:

    $ touch /tmp/database.sqlite
    $ chmod 777 /tmp/database.sqlite