This phase is probably the most familiar to us as developers, as it’s simply a login form. The consumer will send the user to us at the URL we provided in the request token, and the user will have the request token key as a parameter. The access control on this page will look the same as on the rest of the website; if the user has a session already then the page is displayed, otherwise they must be logged in to see it.
Combining PDF Files With Pdftk
For years I’ve used PDF Shuffler for this sort of thing but I wondered if there was an easy way of doing this from the command line this time, since I literally wanted to glue together a bunch of files one after another. Predictably, there is and it’s called pdftk – the PDF Toolkit. Continue reading
PHP OAuth Provider: Request Tokens
The consumer requests a request token (see my earlier post about consuming OAuth), and as a provider, we need to handle that request. In my example, I chose to pass the variables as GET parameters, but you could adapt this to handle POST variables or information contained in HTTP headers.
OAuth Provider Code
We have the same block of code called on every request where we’re negotiating OAuth, and it looks like this:
$this->provider = new OAuthProvider();
// set names of functions to be called by the extension
$this->provider->consumerHandler(array($this,'lookupConsumer'));
$this->provider->timestampNonceHandler(
array($this,'timestampNonceChecker'));
$this->provider->tokenHandler(array($this,'tokenHandler'));
// no access token needed for this URL only
$this->provider->setRequestTokenPath('/v2/oauth/request_token');
// now check the request validity
$this->provider->checkOAuthRequest();
A Prototype API for Joind.In
Things you need to know:
- The service is an HTTP Web Service. Meaning it’s RESTful apart from when it isn’t
- The endpoint is here: http://api.joind.in
- You can fetch data about events and talks (read-only) at this point
- Formats available are HTML or JSON. The service will guess from your accept header but you can override it with
?format=json
or?format=html
- If you need more columns than you get by default, you can add
?verbose=yes
to your request - Pagination is available, with parameters
resultsperpage
(default 20, set to zero for no limits) andstart
(default zero) - The service supports OAuth1.0a, which isn’t useful at this point as we’re read-only but it will come into play as we add functionality
Examples
Events list: http://api.joind.in/v2/events
Information about DPC11: http://api.joind.in/v2/events/603
Talks at DPC11: http://api.joind.in/v2/events/603/talks
Your Thoughts
Comments are welcome on this post. Bugs and feature requests should go to http://joindin.jira.com, read more about Joind.in and its community at http://joind.in/about
Idiot-Proof Deployment with Phing
Once upon a time, a long time ago, I went onto a conference stage for the very first time and said that I thought I might be the world’s ditsiest PHP developer. I actually still think that is pretty true, and if you work with me then you will know that I mostly break and fix things in approximately equal measure. With this in mind, when I launched my own product recently (BiteStats, a thing to automatically email you a summary of your analytics stats every month), I knew that I would need a really robust way of deploying code. I’ve been doing a few different things for a few years, and I’ve often implemented these tools with or for other organisations, but I don’t have much code in production in my own right, weirdly. I decided Phing was the way to go, got it installed, and worked out what to do next.
PHP OAuth Provider: Initial Requirements
OAuth Pages and Endpoints
OAuth has a little more baggage with it than just passing a username and password to an API. As well as your standard service endpoint you will need:
Continue reading
Book Review: Confessions of a Public Speaker
My first observation was that although I thought this would be a pretty serious book, I was laughing! Not just smiling, but actually giggling on a fairly small plane of people doing the short hop over to Amsterdam. I saw a few people trying to read the cover to figure out what this great comedic tome would be :)
Git Tip: What Did I Just Merge?
I have the main repo cloned onto my local machine. Before I do anything, I fetch and merge from the origin and then push back to it, so I know my repo is in sync with the github one. Then I fetch the branch I want to merge – usually one that we’ve got a pull request for. To see what’s in the branch:
git log [branch] --not master
This is nice because it doesn’t show what’s in the master branch of this repo but missing from the incoming branch, it just shows me what’s new on this branch.
I can diff and merge at this point, but more than once I’ve merged and then wondered what changes I have in my repo that aren’t in the github one (this is where it is helpful to have fetched from the remote one first). I have the github repo mapped as “origin” as per the excellent documentation so I can just do:
git diff origin/master..HEAD
This shows me the differences that are in my current repo as compared to origin/master, which is the tip of the main repo shown at the version it was when I last fetched it. I particularly use this when I’ve merged someone’s changes in for testing and am wondering quite what was supposed to happen – sometimes just reading the diff beforehand isn’t enough, it’s only when I get the code merged I realise something unexpected is happening!
New Netbook Feet
Sugru is like slightly toxic plasticene when you first get it out of the box, but it sets like strong rubber. In fact it was perfect for this, the finished feet feel securely attached and they’re slightly squishy so they absorb the shock of me typing or the issues of a slightly uneven surface. Perfect!