1. Go to this page and download the library: Download sajaddp/laravel-bale 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/ */
use Sajaddp\Bale\Facades\Bale;
Bale::replyToMessage(
message: $update['message'],
text: 'پیام شما دریافت شد.',
);
use Sajaddp\Bale\Facades\Bale;
// آپلود فایل محلی
Bale::sendDocument(
chatId: 123456789,
document: new \SplFileInfo(storage_path('app/report.pdf')),
options: ['caption' => 'گزارش آمادهشده'],
);
// استفادهٔ دوباره از فایل موجود در بله
Bale::sendDocument(
chatId: 123456789,
document: 'bale-file-id',
);
// ارسال ویدیو از نشانی اینترنتی
Bale::sendVideo(
chatId: 123456789,
video: 'https://example.com/video.mp4',
);
use Illuminate\Support\Facades\Storage;
use Sajaddp\Bale\Facades\Bale;
$contents = Bale::downloadFile($fileId);
Storage::put('bale/report.pdf', $contents);
use Sajaddp\Bale\Facades\Bale;
Bale::sendMessage(
chatId: 123456789,
text: 'گزارش را دریافت کردید؟',
options: [
'reply_markup' => [
'inline_keyboard' => [
[
['text' => 'بله، دریافت شد', 'callback_data' => 'report_received'],
],
],
],
],
);
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
Route::post('/bale/webhook', function (Request $request) {
$update = $request->all();
// اعتبارسنجی و پردازش رویداد را در برنامهٔ خود انجام دهید.
return response()->noContent();
});