YOURLS is a simple php package that lets you set up your own URL …

YOURLS is a simple php package that lets you set up your own URL shortener, avoiding privacy issues and problems with a shortener going out of  business. I use it on pcurl.us, but with my recent server move I’m switching all of my sites to Nginx, which requires converting apache rewrite rules to Nginx versions.

The official suggestion on the YOURLS site involves heavy use of ifs, which is discouraged in nginx, and is also missing support for info pages and case-sensitive short urls. I wrote a new version, that was better, but it was still more complex than I liked. In setting up another instance for one of the people I host though, I realized that YOURLS has actually made my job a lot easier than I thought. The updated config is below:

server {                                                                                                                                      
  listen 178.33.177.161:80;                                                                                                                   
  server_name pcurl.us;                                                                                                                       
  access_log off;                                                                                                                             
  error_log /var/log/nginx/pcurl.us.error.log;                                                                                                
  root /var/www/pcurl.us/htdocs;                                                                                                              
  location / {
    try_files $uri $uri/ /yourls-loader.php;
    location ~ \.php$ {
      fastcgi_pass   127.0.0.1:9000;
      fastcgi_index  index.php;
      fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
      include        fastcgi_params;
    }
  }
}
 

via http://www.packetcollision.com/2012/01/27/yourls-and-nginx-an-updated-config/

$content_struct = array();$content_struct[‘post_title’] = $name;…

$content_struct = array();
$content_struct['post_title'] = $name;
$content_struct['post_status'] = 'publish';

$content_struct['custom_fields'] = array();
$content_struct['custom_fields'][] = array( 'key' => '_somemeta1', 'value' => 'lorem' );
$content_struct['custom_fields'][] = array( 'key' => '_url', 'value' => 'http://example.com' );

$params = array( 1, $username, $password, $content_struct );

$q = new IXR_Client('http://example.com/xmlrpc.php');
$do = $q->query('wp.newPost', $params );