JENNY MURPHY: Hi, Jenny here from the Glass Developer
Relations team.
And I'm going to show you how to get started with PHP and
the Mirror API.
So I'm going to show you the easiest way to get started is
with a quick start project.
So you can see we have a bunch of different quick start
projects in several different languages.
But today, we're interested PHP.
So let's click here.
You may be interested to know what you're
getting yourself into.
So let's take a look at a demo instance we have, in this
case, written in Java.
So we'll click on this link and open it up.
This gives you an idea of what to expect from one of these
quick starts.
You can see that it gives you a foundation from which you
can build on top of, and build your software quickly, and not
worry about all that boilerplate code.
It also demonstrates a few common patterns we expect you
to use in your Glassware, sending a timeline card with
an attachment, spending timeline items to all of your
users, managing contacts and
subscriptions, stuff like that.
OK, let's see how to get you started.
First thing we're going to want to do is
download the code.
We're going to click on this big link that'll take us to
GitHub, where we can click the download zip button and
download the project.
Let's switch over to our terminal and let's start
setting it up.
So we're going to go into downloads and
unzip what we have.
So we unzip the zip.
File It's going to extract into a
directory, which we'll enter.
And there's a bunch of files in there.
But we only care about one, the config.php file.
So let's open up a text editor.
And take a look at what's in there.
This is the file we're going to modify
the set up the project.
There are a few different parameters that we're going to
set, the API information, which we're going to get from
the API's console, a base URL that tells our project where
it is on our system which depends a lot on your system
configuration, and then finally, a place for it to
store temporary data.
Let's get started with API client configuration.
We have three values and we're going to get them from the
Google API console.
So we'll switch back over to our browser.
You can find the Google API console at
code.google.com/APIs/console.
I've created a new project for us to start with.
But if you've entered this console and you don't have a
project, it's your first time there, it's going to create a
project for you.
So the first thing that we're going to want to do is turn on
the API from the services tab.
So we're going to scroll on down to the Google Mirror API,
right down here.
And we're going to click the toggle.
This may bring up developer terms, which you'll probably
want to agree with to use the API.
Now that it's enabled, we can go up and scroll back up and
set up API access.
So click on API access to bring up this new panel.
Then click on the inviting, large blue button.
It's going to ask some questions about the project
we're installing.
So Awesome Projects, spelt right.
And then it's going to have some more questions about how
our project is set up.
Mirror API software is usually in the form of a web
application and so is this quick start.
So we're going to leave the top set to default.
Down below, we need to tell it where we're going to run it.
We're going to start by running it on our laptop, on
local host.
So we're going to want to turn off HTTPS and tell it running
at local host.
And then whatever the directory is that you're going
to be putting it on your local system.
In my case, a directory called web.
And then the PHP quick start has a php file
for the OAuth callback.
So authtocallback.php, click the Enter.
And then click Create Client ID.
This is going to set up all of our settings for the project.
If things are set up correctly, you should see the
URL to the web directory your have available followed by
[? oauthtocall.php. ?]
Now we just need a copy some entries from this
page into our file.
So first we're going to start with the client ID.
So we're going to copy that.
Come back on over.
And we're going to paste it in here for API client ID.
Then we're going to grab our client secret.
It's just two lines below on the webpage.
A simple API key, which is down in a box just below, down
here, under simple API access.
And then next, we're going to configure the base URL.
As I mentioned, I'm running in a different directory than the
default value is here.
So let's change this to /web.
And then finally, the SQLite database.
The quick start uses SQLite to persist data, which you'll
probably want to change if you actually deploy it.
But it's a great way to get started.
You can just put a file here that's any place the web
server can write to.
I just chose /temp because it's writeable by web servers
in most installations.
But this'll vary based on your configuration.
So let's save that file.
And next, we'll either set up a symlink, or move, or just
somehow get all the stuff into that web accessible directory.
This is another thing that's going to
depend on your system.
Maybe you want to set up a symlink, copy it over.
In my case, I'm just going to move it.
So I'm going to move all those files to that web directory
that I have set up, which is accessible from
my local web server.
So it's all moved in.
Let's take a look at what's there.
So back to the web browser.
I'm going to go to localhost/web, that directory
I set up and we see the authentication page for the
quick start project.
Clicking Accept completes the OAuth dance and gives the
quick start project access to my Glass, the one I'm
wearing right now.
And as message has already been delivered to my Glass
welcoming me to the PHP start project.
You can click on these buttons and it'll do more stuff.
In this case, I'm inserting a picture of Chipotle, our
friendly cat.
And it was delivered.
And that's as simple as it is to set up.
Now you can build software on top of this.
You can modify these functions and copy and paste.
And just to get going on whatever you want to build.
And that's that.
Thanks very much for downloading and running the
PHP quick start project.
We really look forward to seeing what you come up with.