php jsonp接口
Posted hjr_rong
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php jsonp接口相关的知识,希望对你有一定的参考价值。
//jsonp回调
$callback = isset($_GET[‘callback‘]) ? trim($_GET[‘callback‘]) : ‘‘; //jsonp回调参数,必需 $cgc_kanjia_zhuli_rec = new cgc_kanjia_zhuli_rec(); $recmember = pdo_fetchall("SELECT * FROM " . tablename(‘cgc_kanjia_zhuli_member‘) . " WHERE mobile=‘" . $_GPC[‘mobile‘] . "‘"); foreach ($recmember as $k => $v) { $con = " a.uniacid = $uniacid and a.openid = ‘{$v[‘openid‘]}‘ order by a.id desc"; $sql = "SELECT ... WHERE $con"; $rec_list[] = pdo_fetchall($sql); } $result = array(); foreach ($rec_list as $k => $v) { $result = array_merge($result,$v); } $tmp= json_encode($result); //json 数据 echo $callback . ‘(‘ . $tmp .‘)‘; //返回格式,必需
以上是关于php jsonp接口的主要内容,如果未能解决你的问题,请参考以下文章