Esempio n. 1
0
 public function set_input($input)
 {
     $this->header = array();
     //calculate path
     $path = $input['url'];
     $input['get']['client_id'] = Ak_RequestId::getClientId();
     $input['get']['req_id'] = Ak_RequestId::getReqId();
     if (is_array(@$input['get']) && !empty($input['get'])) {
         if (strpos($path, '?') === false) {
             $path .= '?';
         } else {
             $path .= '&';
         }
         foreach ($input['get'] as $k => $v) {
             $path .= urlencode($k) . '=' . urlencode($v) . '&';
         }
     }
     $this->url = $path;
     //calculate POST data
     if (isset($input['data']) || is_array(@$input['post'])) {
         if (isset($input['data'])) {
             $post = $input['data'];
             $this->header[] = 'Content-Type: application/octet-stream';
         } else {
             $post = '';
             foreach ($input['post'] as $k => $v) {
                 $post .= urlencode($k) . '=' . urlencode($v) . '&';
             }
             $this->header[] = 'Content-Type: application/x-www-form-urlencoded';
         }
         $this->is_post = true;
     } else {
         $this->is_post = false;
     }
     $this->data = $post;
     return true;
 }
Esempio n. 2
0
 protected function _get_queryarr($method, $param, $extra)
 {
     $pid = $this->_get_pid();
     $tk = $this->_extra['tk'];
     if (empty($pid)) {
         $this->_add_error("pid is empty");
         return false;
     }
     if ($this->_version == 2) {
         $ret = array('pid' => $this->_extra['pid'], 'tk' => $tk, 'client_id' => Ak_RequestId::getClientId(), 'req_id' => Ak_RequestId::getReqId());
         if (isset($this->_extra['app'])) {
             $ret['app'] = $this->_extra['app'];
         }
         if (isset($this->_extra['instance'])) {
             $ret['instance'] = $this->_extra['instance'];
         }
     } else {
         $ret = array('service' => $this->_get_arch_service_name(), 'pid' => $pid, 'tk' => $tk, 'method' => $method, 'client_id' => Ak_RequestId::getClientId(), 'req_id' => Ak_RequestId::getReqId());
     }
     if (isset($this->_extra['encoding'])) {
         $ret['encoding'] = $this->_extra['encoding'];
     }
     return $ret;
 }