Controller.php 1.0 KB
<?php


namespace app\products\controller;


use app\common\controller\ProductsController;

/**
 * 功能描述 换取access_token
 * Class Controller
 * @package app\products\controller
 * Date: 2020/7/14
 * Time: 16:06
 * @author gxd
 */
class Controller extends ProductsController
{

    protected $appid = "";
    protected $appsecret = "";

    public function _initialize()
    {
        parent::_initialize(); // TODO: Change the autogenerated stub
        $this->appid = config("appid");
        $this->appsecret = config("appsecret");
        $this->allOrigin();
    }

    public function allOrigin() {
        header('Content-Type: text/html;charset=utf-8');
        header('Access-Control-Allow-Origin:*'); // *代表允许任何网址请求
        header('Access-Control-Allow-Methods:POST,GET,OPTIONS,DELETE'); // 允许请求的类型
        header('Access-Control-Allow-Credentials: true'); // 设置是否允许发送 cookies
        header('Access-Control-Allow-Headers: Content-Type,Content-Length,Accept-Encoding,X-Requested-with, Origin');
    }

}