A simple PHP delicious REST example with pecl_http

<?php

$username = 'your_username';
$password = 'your_password';
$url = "https://$username:$password@api.del.icio.us/v1/posts/recent";

$request = new HttpRequest($url, HTTP_METH_GET);
$response = $request->send();
print $response->getBody();
?>

You’ll probably need to view the source in your browser to see the output.

The second argument isn’t required in this call, because HttpRequest defaults to a GET request anyway, but it’s just helpful to see where you can specify the different HTTP methods. The others being, post, put and delete.

2008-11-24 [, , , , , , ] No Comments

Install pecl_http for PHP

You will probably want to ensure that curl supports https before getting underway:

curl -V

Check that the output contains https:

>: curl -V
curl 7.19.2 (i386-apple-darwin9.5.0) libcurl/7.19.2 OpenSSL/0.9.8i zlib/1.2.3
Protocols: tftp ftp telnet dict http file https ftps 
Features: Largefile NTLM SSL libz

If it doesn’t:

sudo port deactivate curl
sudo port install curl +ssl

Once you have curl with https support:

sudo pecl install pecl_http

If you followed my previous howto, you’ll want to move the module to the location specified in your php.ini file:

sudo cp /opt/local/lib/php/extensions/no-debug-non-zts-20060613/http.so /opt/local/lib/php/extensions

Restart lighttpd and then you’ll be good to go.

[, , , , , , , ] No Comments

Install PHP5, lighttpd and Imagick on Mac OS X Leopard

It’s a little tricky getting a nice clean install of PHP5 for OS X 10.5. The packages that I always used to depend on over at Entropy don’t seem to work anymore. At least not for Leopard. A great shame.

I’m now switching to lighttpd for my development server, so have come up with the following recipe to install PHP5 and the great Imagick extension for image manipulation.

(more…)

2008-11-22 [, , , , ] 11 Comments

syslogd slowing my mac to a crawl

For the last few days, I’ve noticed my Mac getting slower, and slower, and slower. To the point where my mouse was jerking about all over the place, and where I was considering smashing my head against the wall next to me.

Opening up Activity Monitor showed that the syslogd and mount_hfs processes were hogging up both of my CPU cores. One each. The greedy bastards.

A little googling, and I found that deleting the file /var/log/asl.db seems to solve the problem. So far, my Mac seems to be speeding along quite merily now, but I’ll give it a few days before confirming mission accomplished.

  1. Restart your Mac.
  2. When at the login screen, enter your password, then hold down shift and login. This will prevent your startup items from launching.
  3. Open Terminal.app and enter the following (at your own risk!!):

    sudo launchctl stop com.apple.syslogd
    sudo rm /var/log/asl.db
    sudo launchctl start com.apple.syslogd
    
  4. Logout, and then log back in again.

Update: That didn’t last long :( It had been zipping along so much faster, but it just started happening again. I’m trying to restart now, but I’ve just got the spinner on screen, and fear that I’m now going to have to force power off. I hope my Drobo turns up asap so I can have a decent backup of my stuff.

2008-09-04 [, , ] No Comments

Extracted Enhanced Podcast Files

I finally found a way to extract the XML files from enhanced podcasts that handle chapters and links.

  1. Open up the podcast file in Quicktime.app
  2. Window > Show Movie Properties
  3. Select the first ‘Text Track’ and ensure it is enabled.
  4. File > Export
  5. Select the ‘Text to QuickTime TeXML’ format

You should then have a lovely XML file. Just need to figure a way to parse the files to get the simple stuff out. Like when to display a link/when a chapter starts, and grab the link/chapter name.

2008-08-16 [, , , , ] No Comments

lighttpd and PHP on CentOS 5

Here’s a quick run down on getting lighttpd and php running on CentOS 5.

yum install lighttpd lighttpd-fastcgi php
mkdir /var/run/lighttpd
touch /var/run/lighttpd/php-fastcgi.socket
chown -R lighttpd:lighttpd /var/run/lighttpd/
vim /etc/php.ini

Add in php.ini the following; cgi.fix_pathinfo = 1. Save and close the file.

Now open up /etc/lighttpd/lighttpd.conf. Uncomment the following line "mod_fastcgi", from the server.modules option. Then ensure that the following is uncommented:

fastcgi.server  = ( ".php" =>
    ( "localhost" =>
        (
            "socket" => "/var/run/lighttpd/php-fastcgi.socket",
            "bin-path" => "/usr/bin/php-cgi"
        )
    )
)

Save the file. Now create a test file, /srv/www/lighttpd/index.php and just include <?php phpinfo(); ?>. Now open your favourite browser and visit http://localhost/index.php. You should be greeted with a friendly PHP page, and you’re set to go.

2008-06-22 [, , , ] 6 Comments

Merge video files with mencoder

To merge video files together with mencoder is simple:

mencoder -oac copy -ovc copy file1.avi file2.avi file3.avi -o full_movie.avi
2008-05-17 [, , , , ] 1 Comment