69c69
< 	function __construct($log = null, $pwd = null) {
---
> 	function __construct($log = null, $pwd = null, $cookiefile="/tmp/.jaiku-cookies.txt") {
74c74,80
< 		$this->cookiefile = $_SERVER["HOME"] . "/.jaiku-cookies.txt";
---
>         // XXX andy: needs to be an absolute path and writable
>         $this->cookiefile = $cookiefile;
>         if (!is_writable($this->cookiefile)) {
>             throw new Exception("Cookiefile must be writable: ". $this->cookiefile);
>         }
>         
>         $this->setpresence_nonce = "";
96,97c102,105
< 		$this->SendToJaiku($postdata,"http://jaiku.com/login");
< 
---
> 		$rv = $this->SendToJaiku($postdata,"http://jaiku.com/login");
>         // XXX andy: we need a nonce to pass the security checks
>         $match = preg_match('/name=\'_nonce\' value=\'(\w+)\'/', $rv, $matches);
>         $this->setpresence_nonce = $matches[1];
117,119c125,126
< 		$postdata = "message=" . urlencode($message)  . "&location=" . urlencode($location) . "&icon=" . urlencode($icon);
< 		$this->SendToJaiku($postdata,"http://jaiku.com/");
< 		
---
> 		$postdata = "message=" . urlencode($message)  . "&location=" . urlencode($location) . "&icon=" . urlencode($icon) . "&_nonce=" . $this->setpresence_nonce;
> 		$rv = $this->SendToJaiku($postdata,"http://jaiku.com/");
131c138
< 		curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)"); 
---
> 		curl_setopt ($ch, CURLOPT_USERAGENT, "JaikuPHP/0.1"); 
141c148
< 	
---
> 	    return $result;
