PHP code example of yisonli / wxmsg

1. Go to this page and download the library: Download yisonli/wxmsg library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

yisonli / wxmsg example snippets


$form->wxmsg('content');

$form->select('app_id', '公众号')->options($app_list)->rules('  'text' => '文本',
        'image' => '图片',
        'news' => '图文',
        'link' => '图文(小程序)',
        'miniprogrampage' => '小程序卡片',
    ])->rules('

public function medias(Request $request)
{
    $app_id = $request->get('a');
    $name = $request->get('q');
    $type = $request->get('t');

    $result = WechatMedia::where('app_id', '=', $app_id)
        ->where('type', '=', $type)
        ->where('name', 'like', "%$name%")
        ->paginate(null, ['media_id', 'name', 'url']);

    foreach ($result as $key => $value) {
        $temp = [
            'id' => $value['media_id'],
            'text' => '<img style="max-width:40px;max-height:40px;" src="'.$value['url'].'" /> ' . $value['name'],
        ];
        $result[$key] = $temp;
    }

    return $result;
}

$router->get('/wechat/reply/medias', 'Wechat\ReplyController@medias');