Exemplo n.º 1
0
 public function handle_request_internal()
 {
     $router_matches = $this->_request->get_router_matches();
     //API说明
     if ($this->_params['doc'] == 1 || $router_matches[0] === '/wiki/') {
         if (!$this->is_allow_call_api) {
             $router_matches = $router_matches[0];
             $router_matches = explode("/", $router_matches);
             $gitName = "";
             foreach ($router_matches as $route_key => $router_match) {
                 if ($router_match == "1.0") {
                     $router_match = "v1";
                 }
                 if (empty($router_match)) {
                     continue;
                 }
                 $gitName .= "_" . $router_match;
             }
             $gitName = ltrim($gitName, "_");
             if ($gitName == "" || $gitName == "wiki") {
                 $gitName = "README";
             }
             $gitContent = self::get_data_from_url("http://git.corp.anjuke.com/mobile/doc/browse/master/docs_customer/API/app2/" . $gitName . ".md", "html");
             $gitContent2 = str_replace("/static/", "http://git.corp.anjuke.com/static/", $gitContent["data"]);
             $gitContent3 = str_replace("/mobile/doc/", "http://git.corp.anjuke.com/mobile/doc/", $gitContent2);
             $this->_request->set_attribute("gitContent", $gitContent3);
             echo $gitContent3;
             exit;
         } else {
             header("location:" . "http://www.anjuke.com", true, 302);
             exit;
         }
     } else {
         $_params = $this->_request->get_parameters();
         $url = $_params['POST_URL'];
         //            $SignatureInterceptor = new SignatureInterceptor();
         //
         //
         //            unset($_params['POST_URL']);
         //
         //            $signres = $SignatureInterceptor->signature($url,array(),$_params,"33684af373d0f6c7");
         //            $heaers = array("key: ee20a1640951687026333adf2083d9b1","sig: ".$signres."");
         $result = Util_CallAPI::get_data_from_url("http://api.anjuke.test/mobile-ajk-broker" . $url, 'json', $_params);
         echo json_encode($result['data']);
         exit;
     }
 }
Exemplo n.º 2
0
 private function sendHouseMsg($authToken, $houseBody)
 {
     try {
         $hosts = APF::get_instance()->get_config('chat_api_host');
         $host = $hosts['host'];
         $real_url = $host . '/message/sendAppMessage?from_idc=1&from=mobile-ajk-broker';
         $headers = array('Content-type: application/json', 'AuthToken: ' . $authToken);
         $data = Util_CallAPI::get_data_from_url($real_url, 'json', $houseBody, $headers);
         return $data;
     } catch (Exception $e) {
         return array('status' => 'ERROR', 'errorMessage' => 'API调用异常', 'errorCode' => '100001');
     }
 }