I'm using this lib: http://stefangabos.ro/php-libraries/zebra-curl/
Within my own class structure to retrieve a token.
<?php
class getToken
{
private $url = "";
private $customHeaders = array('Content-Type: application/x-www-form-urlencoded',);
private $parameters = array();
private $cacheTime = 600;
private $curl;
public $token = false;
public function __construct(){
require_once('lib/Zebra_cURL.php');
$this->curl = new Zebra_cURL();
$this->curl->cache('cache', $this->cacheTime);
$this->curl->option(CURLOPT_HTTPHEADER, $this->customHeaders);
$this->curl->post($this->url, $this->parameters, __CLASS__.'::tokenCallback');
}
public function returnToken(){
return $this->token;
}
public function tokenCallback($result){
if ($result->response[1] == CURLE_OK) {
$body = str_replace(array('\\/','\"'),array('/','"'), html_entity_decode($result->body));
$tokenStart = stripos($body,"<EncryptedAssertion");
$tokenEnd= stripos($body,"EncryptedAssertion>");
$token = substr($body, $tokenStart, $tokenEnd-$tokenStart);
$this->$token = $token;
}else{
$this->token = false;
}
}
}
In the method tokenCallback, I'm trying to set the value of the classes $token parameter, but get the following error: Fatal error: Using $this when not in object context in ....
I've tried setting this using self, but get this error: Fatal error: Access to undeclared static property: getToken::$token
I'm guessing that the way the callback from Zebra_Curl is instantiated is the problem - any one got any ideas on how to get this working?