public static function rest($controller, $user, $re, $parameters, $need_params) { $appid = $parameters["appid"]; $openid = $user->openid; $cookie_key = self::$bind_type . "_" . $openid; //获取绑定的sid $app = new \Justsy\BaseBundle\Management\App($controller); $sessioninfo = $app->getappsession(array("appid" => $appid, "openid" => $openid)); if (empty($sessioninfo)) { return array("status" => "fail", "msg" => "session已过期"); } $data = $sessioninfo["access_token"]; $appinfo = $app->getappinfo(array("appid" => $appid)); $restUrl = $re["inf_url"]; $str_para = array(); if (!empty($parameters)) { //将参数数组转化为字符串 if (is_array($parameters) && !empty($need_params)) { for ($i = 0; $i < count($need_params); $i++) { $pname = $need_params[$i]["paramname"]; $val = isset($parameters[$pname]) ? $parameters[$pname] : $need_params[$i]["paramvalue"]; $str_para[$pname] = $val; } } } $re = Utils::do_post_request_cookie($restUrl . "&" . http_build_query($str_para), null, null, $cookie_key); //对data进行2次转换 $tmpObj = json_decode($re, true); if (isset($tmpObj["data"])) { $txt = $tmpObj["data"]; $fChar = substr($txt, 0, 1); if ($fChar == "{" || $fChar == "[") { $tmpObj["data"] = json_decode($txt, true); $re = json_encode($tmpObj); } } return $re; }