woensdag 28 januari 2009

php curl twitter api

If you receive a 417 http status code when you try to post something using php and curl. Try to send an empty "Expect:" header with your request.

example:

$curl_conn = curl_init ( "http://twitter.com/statuses/update.xml" );
curl_setopt($curl_conn, CURLOPT_HTTPAUTH, CURLAUTH_BASIC );
curl_setopt ($curl_conn, CURLOPT_HTTPHEADER, array ( "Expect:" ) );
curl_setopt($curl_conn, CURLOPT_USERPWD, $user . ":" . $password );
curl_setopt($curl_conn, CURLOPT_POST, true );
curl_setopt($curl_conn, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt ( $curl_conn, CURLOPT_POSTFIELDS, array ( "status" => $msg ) );
$response = curl_exec ( $curl_conn );

donderdag 22 januari 2009

mysql dumps

from:
http://mrothouse.wordpress.com/2007/01/15/mysql-restore-from-compressed-backup/

Copied a compressed database backup from the Production server to the Development server. The database backup file was compressed using bzip2 while piping from mysqldump.

mysqldump -u root -p –databases perfparse | bzip2 -z1 > perfparse.bkp.bz2

bzip2 Options

z = compression
1 = fastest compression (compared to 9 = best compression)

Used bunzip2 to uncompress while piping to mysql due to limited disk space.

bunzip2 < perfparse.bkp.bz2 | mysql -uroot -p

Very basic information, but I do use this blog for referring myself and others back to my notes.