批改状态:合格
老师批语:
<?phpinclude './vendor/autoload.php';use EasyWeChat\Factory;use EasyWeChat\Kernel\Messages\Text;use EasyWeChat\Kernel\Messages\News;use EasyWeChat\Kernel\Messages\NewsItem;$config = ['app_id' => 'wx705529471efe4bf8','secret' => '211da643597922a04ff9e1fca224af1d','token' => 'phplove111','response_type' => 'array',//...];$app = Factory::officialAccount($config);// $app->auto_reply->current();$app->server->push(function ($message) {switch ($message['MsgType']) {case 'text':if (preg_match('/您好/S', $message['Content'])) {return new Text('客服在线时间08:00~18:00');} else {$items = [new NewsItem(['title' => '【普洱茶】降糖,居然让我们越喝越胖!','description' => '你们去年磕的cp,今年已经凉透了,但是无糖饮料却从去年火到了今年,降糖你还相信吗?','url' => 'https://baidu.com','image' => 'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Finews.gtimg.com%2Fnewsapp_bt%2F0%2F13906082969%2F1000&refer=http%3A%2F%2Finews.gtimg.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1633314966&t=10e1a37b4f41e20ded0b5278d7a04e7e',// ...]),];return new News($items);}case 'event':if ($message['Event'] == 'subscribe') {return '你这么好看,关注我不迷路!';}case 'image':return '什么图片,放大我看看';}});// $text = new Text('您好!overtrue。');$response = $app->server->serve();// 将响应输出$response->send();
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号