-
HTTP Toolbox
27 February 2019
Read moreAs Web Developers, we need to know how to work with HTTP from every angle. I gave a 2-hour tutorial at PHP UK that included some of my most trusted tools - but it was sold out and a bunch of people asked me if there was video (there wasn't, tutorials make little sense when videoed). Instead, I thought I'd try to set out a self-study version of the workshop (I rarely teach these days so I'm unlikely to deliver it anywhere else).
There's a slide deck, some exercises and a sample repo on GitHub ... let's dive in!
-
View Only Headers with Curl
08 July 2014
Read moreWhen working with curl, it can give lots of excellent and detailed information, but sometimes it is too much! Today I'm fiddling with the caching headers on a client's application, so I'm only interested in seeing the headers and not the body of the response. Making a HEAD request changes …
-
Chrome Feature: Copy as cURL
04 November 2013
Read moreI surprised someone with my leet skills the other with this technique, so I thought I'd share it on the blog in case anyone else hadn't seen it - I use it ALL the time :) Chrome has a feature which allows you to copy a web request as a curl request, so you see all the various elements of the request on the command line.
-
Github API Access Tokens via Curl
25 September 2012
Read moreI'm working on some demos for a tutorial I'm giving next month and since I'd like to show off Github's API, I needed an access token for it. They have the usual web flow but I'm cutting as many corners as I can to keep the demos nice and quick, so I looked into the support Github has for generating an API key programmatically.
-
Posting Raw Data with Curl
31 August 2012
Read moreThis week I've been working on a feature which handles an incoming API call from an external source (actually Paypal's IPN service). Making external calls into my development platform isn't how I usually work, so instead I captured the body of the request that was being sent, and replayed it …
-
POSTing JSON Data With PHP cURL
22 November 2011
Read moreI got this question the other day: how to send a POST request from PHP with correctly-formatted JSON data? I referred to the slides from my web services tutorial for the answer, and I thought I'd also put it here, with a bit of explanation. After all, publishing your slides is all very well, but if you didn't see the actual tutorial, I often think they aren't too useful.
-
Shortening URLs from PHP with Bit.ly
28 July 2011
Read moreI've been looking around for a really simple API that would be a nice place to get started using web services from PHP - and I realised that bit.ly actually fits the bill really well. They have straightforward api docs on google code, and it's also a pretty simple function!
Here's a simple example, using PHP's curl extension, of using the bit.ly API to get a short URL, using PHP (you need an API key, but if you're a registered bit.ly user, you can log in and then find yours at http://bitly.com/a/your_api_key).
-
Curl and Cookies
12 November 2010
Read moreI noticed the other day that the cheat sheet I have on this site for curl doesn't show how to use cookies, so I thought I'd remedy that omission, and quickly! Being able to use the command line to authenticate and then go on and use part of a site …
-
Deprecated Methods in Pecl_Http
28 October 2010
Read moreI'm a big fan of pecl_http, which I use quite often as I work so regularly with APIs and on systems where I can get it installed, it's much nicer than PHP's curl extension. Recently though I've been often seeing output which reads:
Function HttpRequest::addRawPostData() is deprecated
It isn't …
-
Three Ways to Make a POST Request from PHP
18 January 2010
Read moreEDIT: A more modern take on this topic is here http://www.lornajane.net/posts/2018/make-a-post-request-from-php-with-guzzle
I've been doing a lot of work with services and working with them in various ways from PHP. There are a few different ways to do this, PHP has a curl extension which …
-
Silencing Curl's Progress Output
29 December 2009
Read moreI seem to have been writing a lot of shell scripts to do things with curl lately, and the main difference with piping curl's output to somewhere rather than just looking at it on the screen is that curl will then start outputting a whole bunch of progress information that …
-
Cookies and Curl
21 December 2009
Read morecurl is the C URL library - its a command-line tool for making web requests, with libraries available in many languages. Personally I prefer to use it from the command line and recently I have been using it with cookies for a web services which set a cookie at login and …
-
PUTting data fields with PHP cURL
17 July 2009
Read moreThis is a little post about how to PUT multiple data fields using the PHP cURL extension. Why I wanted to do this in the first place is beyond the scope of this post, since its quite a long story. The curl command line allows data fields to be sent …
-
Using curl and PHP to talk to a REST service
15 September 2008
Read moreHaving recently written articles about curl and about writing a PHP REST server, I thought I'd complete the circle and put here a few notes on using PHP's curl wrapper as a Rest client. Also I had to look some of this up when I needed to actually do it …
-
Curl Cheat Sheet
19 August 2008
Read moreI have a scribbled sheet on my desk, which is my "cheat sheet" for curl, its really short and I thought I'd put my notes here for safe-keeping. If you're visiting, then I hope they help you too.