staff = $staff->getUserByIdList ( $_COOKIE ["staff"] ); return ""; } } Doo::loadCore ( 'uri/DooUriRouter' ); $router = new DooUriRouter (); $routeRs = $router->execute ( Doo::app ()->route, Doo::conf ()->SUBFOLDER ); if ($routeRs ['1'] != "login") { header ( 'Content-Type:text/html;charset=utf-8' ); @header ( "Location: /login" ); } } function authToken(){ $BuildUrl = 'http://gh.cld.smartcost.com.cn'; //$url = $BuildUrl. '/auth/token?staffGH='. urlencode($_COOKIE ['staffGH']); $url = $BuildUrl. '/auth/token'; $data=array("staffGH"=>$_COOKIE ['staffGH']); //echo $url; //echo $this->curl_request($url,$data); $result = json_decode($this->curl_request($url,$data), true); $result['staff']=$_COOKIE ['staff']; echo json_encode($result); //print_r($result); } /** * curl 获取接口数据,data为空时为GET方法,有值则为POST方法 * * @param $url * @param string $data * @return mixed|string */ function curl_request($url, $data = '') { $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_HEADER, 0); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); if($data) { curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data)); } curl_setopt($curl, CURLOPT_TIMEOUT, 10); $data = curl_exec($curl); curl_close($curl); return $data; } /** * 获取get或者POST值 * @param string $name 属性名称 * @return fixed 值 */ private function get_args($name) { if (isset ( $_GET [$name] )) { if (is_array ( $_GET [$name] )) return $_GET [$name]; else { return addslashes ( $_GET [$name] ); //return $_GET [$name] ; } } elseif (isset ( $_POST [$name] )) { if (is_array ( $_POST [$name] )) return $_POST [$name]; else { return addslashes ( $_POST [$name] ); //return $_POST [$name]; } } else return false; } } ?>