Lines Matching refs:this

227             $this->set_api_url ($api_url);
231 $this->set_api_app_id ($app_id);
235 $this->set_api_key ($api_key);
239 $this->set_api_authparams ($username, $password);
243 $this->set_result_format ($result_format);
246 $this->validate_php_extensions ();
258 $this->result = array(
264 $this->print_result ();
278 if ($this->result_format=="json") {
279 return json_encode($this->result);
281 elseif ($this->result_format=="array") {
282 return $this->result;
284 elseif ($this->result_format=="object") {
285 return (object) $this->result;
287 elseif ($this->result_format=="xml") {
291 $this->array_to_xml($xml, $this->result);
305 if ($this->result_format=="json") {
306 print json_encode($this->result);
308 elseif ($this->result_format=="array") {
309 var_dump($this->result);
311 elseif ($this->result_format=="object") {
312 var_dump( (object) $this->result);
314 elseif ($this->result_format=="xml") {
318 $this->array_to_xml($xml, $this->result);
348 $this->array_to_xml($new_object, $value);
367 if($this->api_key !== false)
370 if($this->result_format == "json")
373 if($this->result_format == "xml")
382 $this->exception("Missing php extension ($e)");
396 $this->debug = $debug;
409 if (!in_array($result_format, $this->result_format_available)) {
410 $this->exception ("Invalid result format");
414 $this->validate_php_extensions ();
416 $this->result_format = $result_format;
436 $this->api_url = $api_url;
439 $this->exception("Invalid API URL");
454 $this->exception("Invalid APP id");
457 $this->api_app_id = $app_id;
461 $this->exception("Invalid APP id");
475 $this->api_key = $api_key;
478 $this->api_encrypt = true;
481 $this->exception("Invalid APP id");
495 $this->exception("Invalid username or password");
498 $this->api_username = $username;
499 $this->api_password = $password;
512 $this->set_api_method_validate ($method);
514 $this->api_server_method = strtoupper($method);
525 if(!in_array(strtoupper($method), $this->api_server_valid_methods)) {
526 $this->exception("Invalid method $method");
540 $this->api_server_controller = strtolower($controller);
554 $this->api_server_identifiers = false; // clear this to forget any previous settings
556 if(sizeof($identifiers)>0 && !$this->api_encrypt) {
558 $this->api_server_identifiers = implode("/", $identifiers);
560 elseif (sizeof($identifiers)>0 && $this->api_encrypt) {
561 $this->api_server_identifiers = array();
564 $this->api_server_identifiers['id'] = $i;
567 $this->api_server_identifiers['id'.($cnt+1)] = $i;
590 $this->set_api_method ($method);
592 $this->set_api_controller ($controller);
594 $this->set_api_identifiers ($identifiers);
597 $this->curl_set_connection ($token_file);
599 $this->curl_set_params ($params);
601 $this->curl_set_http_method ();
604 if(!$this->api_encrypt) {
606 $this->curl_add_token_header ($token_file);
609 if ($this->token !== false) {
611 $res = $this->curl_execute ();
613 $this->result = (array) $res;
616 if ($this->result['code']=="401" && $token_file!==false) {
618 $this->delete_token_file ($token_file);
620 $this->curl_add_token_header ($token_file);
622 $res = $this->curl_execute ();
624 $this->result = (array) $res;
628 elseif ($this->api_encrypt) {
630 $res = $this->curl_execute ();
632 $this->result = (array) $res;
635 $this->curl_save_headers ();
648 if ($this->Connection==false) {
650 $this->Connection = curl_init();
653 if($this->api_server_controller===false) {
654 $url = $this->api_url.$this->api_app_id."/";
657 …$url = $this->api_url.$this->api_app_id.str_replace("//", "/", "/".$this->api_server_controller."/…
661 curl_setopt_array($this->Connection, array(
665 CURLOPT_VERBOSE => $this->debug,
694 if (is_array($params) && !$this->api_encrypt ) {
697 if ($this->api_server_method == 'GET')
698 …url_setopt($this->Connection, CURLOPT_URL, $this->api_url.$this->api_app_id.str_replace("//", "/",…
700 curl_setopt($this->Connection, CURLOPT_POSTFIELDS, json_encode($params));
704 elseif ($this->api_encrypt) {
708 if(!is_array($this->api_server_identifiers))
709 $this->api_server_identifiers = array();
712 $params = array_merge($this->api_server_identifiers, $params);
713 $params['controller'] = $this->api_server_controller;
716 …$encrypted_request = base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $this->api_key, json_encode…
722 …curl_setopt($this->Connection, CURLOPT_URL, $this->api_url."?app_id=".$this->api_app_id."&enc_requ…
733 curl_setopt($this->Connection, CURLOPT_CUSTOMREQUEST, $this->api_server_method);
749 $this->token = trim($token[0]);
750 $this->token_expires = trim($token[1]);
752 if (strlen($this->token)<2 && $this->token_expires < time()) {
754 $this->curl_authenticate ();
756 $this->write_token_file ($token_file);
760 $this->curl_authenticate ();
762 $this->write_token_file ($token_file);
768 $this->curl_authenticate ();
772 $this->curl_add_http_header ("token", $this->token);
791 curl_setopt($this->Connection, CURLOPT_HTTPHEADER, $headers);
805 fwrite($myfile, $this->token);
807 fwrite($myfile, $this->token_expires);
812 $this->exception("Cannot write file $filename");
832 $this->exception("Cannot write file $token_file");
844 $resp = curl_exec($this->Connection);
847 if (curl_errno($this->Connection)) {
848 $this->exception("Curl error: ".curl_error($this->Connection));
864 $this->response_headers = curl_getinfo($this->Connection);
880 CURLOPT_URL => $this->api_url.$this->api_app_id."/user/",
900 CURLOPT_USERPWD => $this->api_username.":".$this->api_password,
919 $this->exception("Curl error: ".curl_error($c_auth));
928 $this->token = $auth_resp->data->token;
929 $this->token_expires = strtotime($auth_resp->data->expires);
932 $this->exception("Cannot obtain access token");
938 $this->result = $auth_resp;