mac 安装 Composer 

//composer安装成功
curl -sS https://getcomposer.org/installer | php
//将composer.phar移动到 /usr/local/bin/composer支持全局访问composer命令
mv composer.phar /usr/local/bin/composer
//验证
composer -v


composer require overtrue/wechat:~3.1 -vvv

ci框架下载直接使用

直接贴代码:
<?php

include 'vendor/autoload.php';
use EasyWeChat\Factory;

class Index extends Ci_Controller {
    protected $app = NULL;
    public function __construct(){
        parent::__construct();
        //加载easywechat配置文件
$this->load->config("easywechat");
        //实例化easywechat包
        //更新菜单
$this->app->menu->create(config_item("menu"));
}
    public function index(){
        $app = $this->app;
        $app->server->push(function ($message) {

return 'hello';
        }
}
}

config 创建 easywechat.php文件
$config["wechat"] = [
'debug' => true,
'app_id' => 'xxx',
'secret' => 'xxx',
//'token' =>'weixin',
'response_type' => 'array',
'log' => [
'level' => 'debug',
'file' => '/tmp/easywechat.log',
],
'oauth' => [
'scopes' => ['snsapi_userinfo'],
'callback' => "info",
],

];
$config['menu'] = [
    [
        "type" => "click",
        "name" => "今日歌曲",
        "key"  => "V1001_TODAY_MUSIC"
    ],
    [
        "name"       => "菜单",
        "sub_button" => [
            [
                "type" => "view",
                "name" => "搜索",
                "url"  => "http://www.soso.com/"
            ],
            [
                "type" => "view",
                "name" => "视频",
                "url"  => "http://v.qq.com/"
            ],
            [
                "type" => "click",
                "name" => "赞一下我们",
                "key" => "V1001_GOOD"
            ],
        ],
    ],
];
写的不是很详细,如有疑问请加群讨论















 




 

posted on 2017-05-16 14:40  程序小院  阅读(276)  评论(0编辑  收藏  举报