【发布时间】:2018-04-11 20:43:48
【问题描述】:
我有两个项目要使用this SDK。一个是 Laravel 5.4,第二个是 Laravel 5.5。 使用 Laravel 5.4 消息发送顺利,但使用 Laravel 5.5 我收到以下错误:
代码是:
use App\Http\Controllers\TelegramController;
.
.
.
TelegramController::sendNotification('contactMail', $params);
电报控制器:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Validator;
use Telegram\Bot\Laravel\Facades\Telegram;
class TelegramController extends Controller {
public function getHome()
{
return view('/');
}
public function getUpdates()
{
$updates = Telegram::getUpdates();
dd($updates);
}
public static function sendNotification($type, $params){
switch($params['subject']){
case 'contact':
$subject = 'Contact';
break;
case 'pricequote':
$subject = 'PriceQuote';
break;
}
switch($type){
case 'contactMail':
$message = 'New message from:: ' . $params['email'] . ". Subject: " . $subject;
}
Telegram::sendMessage([
'chat_id' => 'mychatId',
'text' => $message,
]);
}
}
有什么问题?
编辑:
我忘记在 config/app.php 中添加这些行(谢谢 Pyramid 先生)
现在我有另一个错误,它找不到TelegramOtherException。我重新安装了它,但仍然出现错误:
【问题讨论】:
-
你是如何安装 sdk 的?
-
我将
"irazasyed/telegram-bot-sdk": "2.*"放入composer.json,而不是运行composer update -
检查我的答案并按照文档进行操作
标签: php laravel telegram telegram-bot laravel-5.5