Using CURL in PHP

In Python, to read a URL, I do the following:

import urllib
data = urllib.urlopen('http://foo.com/').read()

PHP links against cURL, which lets you accomplish the same thing … in five lines of code.

If this is something you plan to do more than, say, once, you’ll want an easier way of doing this. Here’s the function I use:

function readUrl($url) {
	$curlHandle = curl_init();
	curl_setopt($curlHandle, CURLOPT_URL, $url);
	curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, 1);
	$data = curl_exec($curlHandle);
	
	if (!$data) {
		print curl_errno($curlHandle) . "  " . curl_error($curlHandle);
		curl_close($curlHandle);
		return false;
	}

	curl_close($curlHandle);

	return $data;
}

(keywords: curl php wrapper example)

congrats Mark and Catie!

Mark Erelli and Catie Curtis just won the grand prize in the International Songwriting Competition.

Their song, “People Look Around,” is a stark, honest portrait of the United States and a cry for humanity — for us to be more human:

Mississippi River divides this land in two,
Like the way we tend to think of things;
Black and white, red and blue.
If they can keep us fighting about marriage and God,
There’ll be no one left to notice if the leaders do their jobs.

(lyrics, lyrics and mp3)

the importance of net neutrality

the execs at the telcos (perhaps the same people whose secretaries print their emails — who knows) have this great idea to make money off the internet: meter everything.

their argument is that google is getting a “free ride” on their network. well, no, they aren’t. they are paying for bandwidth at their end, and you, the end user, are paying on your end as well.

that’s like at&t saying they should get 5% of the profits of every telemarketing call. sigh.

for a great overview of this, listen to Burnie Burns’s SXSW keynote and read Brad Templeton’s essay. (Scot Hacker has notes from Burnie’s talk.)

technical confidence

Sally Carson, a designer I met at SXSW, put together a thoughtful examination of what happens when people are intimidated by technology:

I think that instilling confidence into our audience — whether on the web or on an electronic device — is an important component of good interface design. Something about Phil’s phone intimidates him, and eventhough he is embarrassed when his phone rings so loudly (keep in mind, embarrassment is a strong motivational tool) he doesn’t even attempt to change the settings himself because he is sure he won’t be able to figure it out.

free music from verve

I found a card at SXSW for a free music sampler from Verve. They want you to go to verveforecast.com/sxsw, then register, thenenter in the “download code” of vforecastsxsw.

The music sampler (Jamie Cullum, Brazilian Girls, Jackie Greene, Rhett Miller, Susan Tedeschi, Teddy Thompson) comes in four formats, all of which are annoying:

The QuickTime files are .mov files with an embedded AAC track. However, QuickTime won’t let me extract the track cleanly — I can only export as AIFF, AU (why?) and WAVE.

Glenn Anderson has some handy QuickTime Exporters, including one that will save it as AAC (after downsampling from 256 to 128).

Anyone have any better solutions?