mac CodeIgniter和EasyWeChat 开发微信公众号

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"
            ],
        ],
    ],
];
写的不是很详细,如有疑问请加群讨论















 




 

转载于:https://www.cnblogs.com/chaihy/p/9045932.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值