
1、在宝塔配置文件中找到以下语句
access_log /www/******
error_log /www/******
替换成:
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept";
add_header Access-Control-Allow-Methods "GET, POST, OPTIONS";
access_log /www/******
error_log /www/******
2、用php语句建一个接口
<?php
$cfg_NotPrintHead = false;
header("Content-Type: text/html; charset=utf-8");
include_once (dirname(__FILE__)."/include/common.inc.php");
error_reporting(E_ALL || ~E_NOTICE);
require_once(DEDEINC.'/json.class.php');
$reval = array();
$dsql->SetQuery("SELECT id,title FROM `de_kd_archives` where typeid='栏目id' and LIMIT 5");
$dsql->Execute('me');
while ($row = $dsql->GetArray('me')) {
//$row['title'] = gb2utf8($row['title']);
$reval[] = $row;
}
$json = new Services_JSON(SERVICES_JSON_SUPPRESS_ERRORS);
echo $json->encode($reval);
?>
标签: 宝塔
上面是“如果用宝塔实现dedecms织梦接口调用”的全面内容,想了解更多关于 织梦cms 内容,请继续关注web建站教程。
当前网址:https://m.ipkd.cn/webs_784.html
声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

端午节习俗探源:门上艾草的深远寓意与背后故事
WordPress技巧如何显示评论作者ip地址
PixVerse R1:爱诗科技打造,全球首个通用实时世界模型
YouWare:一款集开发/协作/变现于一体的一站式AI编程社区与开发平台
铜梁区博物馆线上入口