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


















  • 相关阅读:
    Python rindex()方法
    Python rfind()方法
    Python replace()方法
    服务器技术综述(三)
    服务器技术综述(二)
    服务器技术综述(一)
    TensorRT-优化-原理
    TensorRT-安装-使用
    TensorRT 加速性能分析
    GPU加速:宽深度推理
  • 原文地址:https://www.cnblogs.com/chaihy/p/9045932.html
Copyright © 2011-2022 走看看