当前位置 : 主页 > 网络编程 > PHP >

PHP端支持跨域.php

来源:互联网 收集:自由互联 发布时间:2021-06-28
PHP端支持跨域.php protected function ajaxxPHP() { //支持跨域 header('Access-Control-Allow-Headers: Content-Type, Authorization'); header('Access-Control-Allow-Methods: OPTIONS, GET, POST, PUT, DELETE'); header('Access-Control-Allow
PHP端支持跨域.php
protected function ajaxxPHP()
    {
        //支持跨域
        header('Access-Control-Allow-Headers: Content-Type, Authorization');
        header('Access-Control-Allow-Methods: OPTIONS, GET, POST, PUT, DELETE');
        header('Access-Control-Allow-Origin: *');
		header('Access-Control-Max-Age: 2592000'); //1个月内不需要再发送OPTIONS预检查请求
		
        if (REQUEST_METHOD == 'OPTIONS') {
            header("HTTP/1.1 204 No Content"); //OPTIONS请求返回空内容的204状态码
			exit();
        }
        //检查IP
        if ($this->checkIP()) {
            APIResponse::error('IP禁止访问,请联系管理员');
        }
        parent::_initialize(); // TODO: Change the autogenerated stub
        //检查传递的company_id参数
        if (!is_numeric(self::getRequestCompanyId()) || self::getRequestCompanyId() < 0) {
            ALog::info('当前接口未传递企业ID');
            //APIResponse::error('未传递正确的企业ID');
        }
    }
上一篇:code.class.php
下一篇:sensitiveWords.php
网友评论