示例#1
0
 public function render($__data__ = null, $__view__ = null)
 {
     //get friend message
     if (isset($__data__['code']) && $__data__['code'] > 0) {
         $__data__['msg'] = Core::get_lang_text($__data__['code']);
     }
     //json
     $response = json_encode($__data__, JSON_UNESCAPED_UNICODE);
     if (!empty($_GET['callback'])) {
         //jsonp
         if (!preg_match('/^[a-z0-9\\._]+$/i', $_GET['callback'])) {
             throw new Exception("callback error,callback:{$_GET['callback']}", Errno::PARAM_INVALID);
         }
         $response = $_GET['callback'] . "({$response})";
         //for iframe submit mode
         if (substr($_GET['callback'], 0, 7) == 'parent.') {
             header('Content-Type: text/html; charset=utf-8');
             $response = "<script type='text/javascript'>{$response}</script>";
         }
     }
     echo $response;
 }