<?php
/**
 * 易优CMS
 * ============================================================================
 * 版权所有 2016-2028 海南赞赞网络科技有限公司，并保留所有权利。
 * 网站地址: http://www.eyoucms.com
 * ----------------------------------------------------------------------------
 * 如果商业用途务必到官方购买正版授权, 以免引起不必要的法律纠纷.
 * ============================================================================
 * Author: 小虎哥 <1105415366@qq.com>
 * Date: 2018-4-3
 */

use think\Model; 
use think\Request;

/*
 * 草稿管理接口实现
 */
class draft extends base{

    public function __construct($config){
        parent::__construct($config);
    }

    /**
     * 新增草稿
     */
    public function add($data = array())
    {
        $post_data = array(
            'articles' => $data,
        );
        $url = "https://api.weixin.qq.com/cgi-bin/draft/add?access_token=" . $this->access_token;
        $response = $this->httpRequest($url, 'POST', json_encode($post_data,JSON_UNESCAPED_UNICODE));
        $params = array();
        $params = json_decode($response,true);
        if (isset($params['errcode']))
        {
            $errmsg = isset($this->codeArr[$params['errcode']]) ? $this->codeArr[$params['errcode']] : $params['errmsg'];
            echo "<h3>error:</h3>" . $params['errcode'];
            echo "<h3>msg  :</h3>" . $errmsg;
            exit;
        }

        return $params;
    }
}