zoukankan      html  css  js  c++  java
  • 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 EasyWeChatFactory;

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


















  • 相关阅读:
    python3 bs4库
    python3 requests 库学习
    thinkPHP远程代码执行漏洞
    centos 数据库忘记密码
    centos 安装 nfs
    中间人工具---MITMF
    微信公众号授权获取codequ
    vue element 倒计时
    vue常见登陆注册按钮切换效果
    VUE3.0重新定向
  • 原文地址:https://www.cnblogs.com/chaihy/p/9045932.html
Copyright © 2011-2022 走看看