EasyWeChat制作公众号推送

<?php

namespace App\Http\Controllers\Api;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Input;  
use Auth,Redirect;  
use Validator;  
use EasyWeChat\Factory;
use EasyWeChat\Foundation\Application;
use DB;  



/**
     * 微信推送
     * @param  Request
     * @return [json]
     */


    public function wxPush(Request $request)
    {

        $appid       =    config('wechat.appId');
        $secret      =    config('wechat.secret');
        $config = [
            'app_id' => $appid,
            'secret' => $secret,
            'response_type' => 'array',

        ];

        $app = new Application($config);


        $app->notice->send([
            'touser' => 'oFFxE1BofS*****',               //用户openid
            'template_id' => '1KwPvazjT0_8*****6M5X8',    //模拟id
            'url' => 'https://easywechat.org',
            'data' => [
                'key1' => 'VALUE',
                'key2' => 'VALUE2'
            ],
        ]);
    }

猜你喜欢

转载自blog.csdn.net/weixin_39201566/article/details/86148923