首页 > 代码库 > 微信分享

微信分享

<?php
/**
 * Description of WxShare
 *微信分享
 * @author xinjun
 */
namespace Controller\Wx;

use Controller\Home\HomeBase;
use Model\Wx\UserModel;
use Model\Wx\TokenModel;
use Framework\Net\Request;

class WxShare extends HomeBase
{
    public function __construct()
    {
        parent::__construct();
    }
    
    /**
     * 分享配置信息
     * @return type
     */
    public function getConfig()
    {
        $url = $_POST[‘url‘];
        $conf = array();
        $conf[‘debug‘] = true;
        $conf[‘appId‘] = $this->getAppid();
        $conf[‘timestamp‘] = time();
        $conf[‘nonceStr‘] = "Wm3WZYTPz0wzccnW";
        $conf[‘signature‘] = $this->getSignature($conf[‘nonceStr‘],$conf[‘timestamp‘],$url);
        $conf[‘jsApiList‘] = [‘onMenuShareTimeline‘,‘onMenuShareAppMessage‘];
//        print_r($conf);exit;
         return $this->getData($conf);//json_encode($conf,JSON_UNESCAPED_SLASHES) ;
    }

    /**
     * 获取appid
     * @return type
     */
    public function getAppid()
    {
        $tokenModel = new TokenModel();
        $appidData = http://www.mamicode.com/$tokenModel->getAccessToken(array(‘nf_type‘=>1));"https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token=".$accesstokenData[‘nf_val‘]."&type=jsapi";
            $https = true;
            $method = ‘get‘;
            $data = http://www.mamicode.com/null;>

  

微信分享