Adding Custom Headers to Every Request with Chrome

I’m working on an API which uses OAuth2, but it also has an HTML output handler so I actually do quite a lot of my development in the browser for read-only stuff (I wrote an earlier article about output handlers including the HTML output handler). I fell across an extension for Chrome called ModHeader (WTF kind of URL is that, google?) which does this trick for me!

Once I have the access token, I add the Authorization header using ModHeader and it sends it on all requests to this API, so I can still use my HTML output handler and be logged in. It’s useful for sending custom headers of all kinds for different tools, so I thought I’d mention it!

Book Review: MongoDB and PHP

Despite having been toying with MongoDB and PHP for quite a while, I’ve only just picked up and read the “MongoDB and PHP” by Steve Francia, published by O’Reilly (disclaimer: I’ve collaborated with Steve on a few articles and he sent me a copy of the book to read)

Continue reading

Using OAuth2 for Google APIs with PHP

I’ve been working on something recently where I’m pulling information from lots of places onto a dashboard. Each API has its own little quirks so I’m trying to write up the ones that weren’t idiot-proof, mostly so I can refer back to them later when I need to maintain my system!

I’ve written about Google and OAuth before, but that was OAuth v1.0, and they are introducing OAuth2 for their newer APIs; in this example I was identifying myself in order to use the Google Plus API (which turns out not to do anything you’d expect it to do, but that’s a whole separate blog post!). Continue reading

Using JIRA’s REST API to Create a Dashboard

If you read this blog often, you’ll know that I am:

  • crazy about APIs
  • living with some accessibility issues

Put these two things together and what do you get? Actually don’t answer that! Today what you get is an example of integrating with JIRA’s REST API, because their recent “upgrade” locked me out of the issue listings pages completely and I really do need to be able to see a list of bugs! Their bug editing screen is quite usable, so it’s just the list that I need here, but you could easily call their other API methods as you need to. Continue reading

SQL JOINing a Table to Itself

Getting two sets of information from one table in a select statement often leads people to write subselects, but it really doesn’t matter that this is the same table twice, we can just give it a new alias and treat it as if it were a different table. This is one of those techniques where, once you’ve seen it, it’s really obvious, but until that point it can be very confusing. I explained this to someone else recently, so I thought I’d capture it here in case it’s helpful to anyone else.

Consider that tried-and-tested example: employees and managers. Here’s the staff table from the database (today’s imaginary data isn’t particularly imaginative, sorry):

mysql> select * from staff;
+----+------------+-----------+------------+
| id | first_name | last_name | manager_id |
+----+------------+-----------+------------+
|  1 | Hattie     | Hopkins   |          4 |
|  2 | Henry      | Hopkins   |          4 |
|  3 | Harry      | Hopkins   |          5 |
|  4 | Helen      | Hopkins   |       NULL |
|  5 | Heidi      | Hopkins   |          4 |
|  6 | Hazel      | Hopkins   |          1 |
+----+------------+-----------+------------+
6 rows in set (0.00 sec)

Continue reading

5 Things To Do With A Training Budget of Zero

Training budgets are never generous enough to give us everything we think we need to keep our skill sets improving, however many people will be lucky enough to get something. If your training budget totals precisely zero pounds (or euros, or dollars, or whatever your local currency is), what do you do? Sulk until they give you something more? Or make the most of what you have? Continue reading

Ideas of March: Write and Read

Today you may see a few folk dusting off their blogs to celebrate “Ideas of March” where we blog about blogging and pledge our good intentions to blog for another year. Personally, I think I blog more than enough already, but I’ve been thinking recently about writing, ideas and how important two-way knowledge exchange is. Continue reading

Speaking at Leeds PHP

On Monday 19th March I’ll be speaking at PHP Leeds. The topic is all things git and github; as an open source project lead I see lots of very capable programmers taking their first steps with github. In this session we’ll talk about how you can use these tools to contribute to open source (or your own projects, of course), covering both “what to click in the web interface” and “what to type at the command line” for git and github respectively. Come along if you want to know more about git, open source, or github!

Generating Callgraph with XHGUI

I had a frustrating bug the other day with a new XHGUI install, I am working on creating a VM for my new PHP tools course I am teaching in March and I wanted to pre-install and part-install a bunch of things so that I can show some great tools in a limited amount of time. My XHGUI wasn’t quite right though; it couldn’t generate the callgraph for me. Instead, it said:

failed to shell execute cmd=" "" -Tpng"

Continue reading