- $this->cookiejar = tempnam(sys_get_temp_dir(), 'cookies');
+ $this->cookiejar = tempnam(get_temppath(), 'cookies');
+ }
+
+ function __destruct() {
+ if (file_exists($this->cookiejar))
+ unlink($this->cookiejar);
curl_setopt ($ch, CURLOPT_URL, $this->pod . "/stream");
curl_setopt ($ch, CURLOPT_COOKIEFILE, $this->cookiejar);
curl_setopt ($ch, CURLOPT_COOKIEJAR, $this->cookiejar);
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt ($ch, CURLOPT_URL, $this->pod . "/stream");
curl_setopt ($ch, CURLOPT_COOKIEFILE, $this->cookiejar);
curl_setopt ($ch, CURLOPT_COOKIEJAR, $this->cookiejar);
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
// Token holen und zurückgeben
preg_match($this->token_regex, $output, $matches);
return $matches[1];
}
// Token holen und zurückgeben
preg_match($this->token_regex, $output, $matches);
return $matches[1];
}
function login($username, $password) {
$datatopost = array(
'user[username]' => $username,
'user[password]' => $password,
'authenticity_token' => $this->_fetch_token()
);
function login($username, $password) {
$datatopost = array(
'user[username]' => $username,
'user[password]' => $password,
'authenticity_token' => $this->_fetch_token()
);
curl_setopt ($ch, CURLOPT_URL, $this->pod . "/users/sign_in");
curl_setopt ($ch, CURLOPT_COOKIEFILE, $this->cookiejar);
curl_setopt ($ch, CURLOPT_COOKIEJAR, $this->cookiejar);
curl_setopt ($ch, CURLOPT_URL, $this->pod . "/users/sign_in");
curl_setopt ($ch, CURLOPT_COOKIEFILE, $this->cookiejar);
curl_setopt ($ch, CURLOPT_COOKIEJAR, $this->cookiejar);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt ($ch, CURLOPT_POST, true);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $poststr);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt ($ch, CURLOPT_POST, true);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $poststr);
if($info['http_code'] != 302) {
throw new Exception('Login error '.print_r($info, true));
}
if($info['http_code'] != 302) {
throw new Exception('Login error '.print_r($info, true));
}
// post-daten vorbereiten
$datatopost = json_encode(array(
'aspect_ids' => 'public',
// post-daten vorbereiten
$datatopost = json_encode(array(
'aspect_ids' => 'public',
// header vorbereiten
$headers = array(
'Content-Type: application/json',
'accept: application/json',
'x-csrf-token: '.$this->_fetch_token()
);
// header vorbereiten
$headers = array(
'Content-Type: application/json',
'accept: application/json',
'x-csrf-token: '.$this->_fetch_token()
);
curl_setopt ($ch, CURLOPT_URL, $this->pod . "/status_messages");
curl_setopt ($ch, CURLOPT_COOKIEFILE, $this->cookiejar);
curl_setopt ($ch, CURLOPT_COOKIEJAR, $this->cookiejar);
curl_setopt ($ch, CURLOPT_URL, $this->pod . "/status_messages");
curl_setopt ($ch, CURLOPT_COOKIEFILE, $this->cookiejar);
curl_setopt ($ch, CURLOPT_COOKIEJAR, $this->cookiejar);
curl_setopt ($ch, CURLOPT_POST, true);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $datatopost);
curl_setopt ($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt ($ch, CURLOPT_POST, true);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $datatopost);
curl_setopt ($ch, CURLOPT_HTTPHEADER, $headers);
if($info['http_code'] != 201) {
throw new Exception('Post error '.print_r($info, true));
}
if($info['http_code'] != 201) {
throw new Exception('Post error '.print_r($info, true));
}