source: pro-violet-viettel/sourcecode/application/libraries/vservices.php @ 461

Last change on this file since 461 was 457, checked in by dungnv, 11 years ago
File size: 1.7 KB
Line 
1<?php
2
3Class VServices {
4       
5        private $_apiUrl;
6        private $_curlObj;
7        private $_userId;
8        private $_password;
9       
10        private $_httpUser;
11        private $_httpPasswd;
12       
13        public function __construct() {
14        }
15        public function setApiUrl($url) {
16                $this->_apiUrl = $url;
17        }
18       
19        public function setConnection($curl) {
20                $this->_curlObj = $curl;
21        }
22       
23        public function setUserId ($userId) {
24                $this->_userId = $userId;
25        }
26       
27        public function setPassword ($password) {
28                $this->_password = $password;
29        }
30       
31        public function getPrivateTree () {
32                $this->_curlObj->create($this->_apiUrl. 'space/dir/isgetall/1');
33                $this->_curlObj->option(CURLOPT_BUFFERSIZE, 10);
34                $this->_curlObj->options(array(CURLOPT_BUFFERSIZE => 10));
35                $post =  $this->_userId ? array('userid' => $this->_userId) : array();
36                $this->_curlObj->post($post);
37                return $this->_curlObj->execute();
38        }
39       
40        /**
41         * $aryParams
42         *
43         * @param unknown $action
44         * @param unknown $aryParams
45         */
46
47        public function actionExecute ($action, $aryParams = array(), $module = 'space') {
48                $this->_curlObj->create($this->_apiUrl. $module .'/'.$action);
49                $this->_curlObj->option(CURLOPT_BUFFERSIZE, 10);
50                $this->_curlObj->options(array(CURLOPT_BUFFERSIZE => 10));
51               
52                if ($this->_httpUser && $this->_httpPasswd) {
53                        $this->_curlObj->http_login($this->_httpUser, $this->_httpPasswd);
54                }
55               
56                if ($this->_userId) $aryParams['userid'] = $this->_userId;
57                if (count($aryParams) > 0) $this->_curlObj->post($aryParams);
58               
59                $result = $this->_curlObj->execute();
60               
61                write_file('log.txt', var_export($result, true)."\n".var_export($this->_apiUrl. $module .'/'.$action, true)."\n".var_export($aryParams, true));
62               
63                return $result;
64        }
65
66       
67       
68        public function __destruct() {
69               
70        }
71}
Note: See TracBrowser for help on using the repository browser.