You've already forked qlg.tsgz.moe
addons
app_download_files
extend
hyhproject
mobile
oss
static
thinkphp
lang
library
think
cache
config
controller
db
debug
exception
log
model
paginator
process
response
Json.php
Jsonp.php
Redirect.php
View.php
Xml.php
session
template
view
App.php
Build.php
Cache.php
Collection.php
Config.php
Console.php
Controller.php
Cookie.php
Db.php
Debug.php
Env.php
Error.php
Exception.php
File.php
Hook.php
Lang.php
Loader.php
Log.php
Model.php
Paginator.php
Process.php
Request.php
Response.php
Route.php
Session.php
Template.php
Url.php
Validate.php
View.php
traits
tpl
.htaccess
LICENSE.txt
README.md
base.php
convention.php
helper.php
logo.png
start.php
upload
vendor
wxtmp
.gitignore
.htaccess
.user.ini
404.html
H5B854518.wgt
admin.php
app-release.apk
app_download.html
cash.lock
demo.php
get_startup.php
get_version.php
get_version_new.php
hyhproject.tar.gz
index.html
index.php
reg.lock
robots.txt
59 lines
2.0 KiB
PHP
Executable File
59 lines
2.0 KiB
PHP
Executable File
<?php
|
||
// +----------------------------------------------------------------------
|
||
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
|
||
// +----------------------------------------------------------------------
|
||
// | Copyright (c) 2006~2017 http://thinkphp.cn All rights reserved.
|
||
// +----------------------------------------------------------------------
|
||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||
// +----------------------------------------------------------------------
|
||
// | Author: liu21st <liu21st@gmail.com>
|
||
// +----------------------------------------------------------------------
|
||
|
||
namespace think\response;
|
||
|
||
use think\Request;
|
||
use think\Response;
|
||
|
||
class Jsonp extends Response
|
||
{
|
||
// 输出参数
|
||
protected $options = [
|
||
'var_jsonp_handler' => 'callback',
|
||
'default_jsonp_handler' => 'jsonpReturn',
|
||
'json_encode_param' => JSON_UNESCAPED_UNICODE,
|
||
];
|
||
|
||
protected $contentType = 'application/javascript';
|
||
|
||
/**
|
||
* 处理数据
|
||
* @access protected
|
||
* @param mixed $data 要处理的数据
|
||
* @return mixed
|
||
* @throws \Exception
|
||
*/
|
||
protected function output($data)
|
||
{
|
||
try {
|
||
// 返回JSON数据格式到客户端 包含状态信息 [当url_common_param为false时是无法获取到$_GET的数据的,故使用Request来获取<xiaobo.sun@qq.com>]
|
||
$var_jsonp_handler = Request::instance()->param($this->options['var_jsonp_handler'], "");
|
||
$handler = !empty($var_jsonp_handler) ? $var_jsonp_handler : $this->options['default_jsonp_handler'];
|
||
|
||
$data = json_encode($data, $this->options['json_encode_param']);
|
||
|
||
if ($data === false) {
|
||
throw new \InvalidArgumentException(json_last_error_msg());
|
||
}
|
||
|
||
$data = $handler . '(' . $data . ');';
|
||
return $data;
|
||
} catch (\Exception $e) {
|
||
if ($e->getPrevious()) {
|
||
throw $e->getPrevious();
|
||
}
|
||
throw $e;
|
||
}
|
||
}
|
||
|
||
}
|