شـروحات اساسيات لغه PHP
169 subscribers
9 photos
1 video
19 links
Download Telegram
بعد ما تعطي المعرف حيرسل لك توكن بوت يصير هيج


Done! Congratulations on your new bot. You will find it at t.me/insta_checkbot. You can now add a description, about section and profile picture for your bot, see /help for a list of commands. By the way, when you've finished creating your cool bot, ping our Bot Support if you want a better username for it. Just make sure the bot is fully operational before you do this.

Use this token to access the HTTP API:


1177022147:AAE5eB_Zvg1gMmWSNzO2i2qwJ3yyHoDjBhY

هذا هو التوكن ☝️☝️☝️
Keep your token secure and store it safely, it can be used by anyone to control your bot.

For a description of the Bot API, see this page: https://core.telegram.org/bots/api
هناك متغيرات مهمه توضع بعد فاكشن الاتصال
مثل :

$username تعني اسم المستخدم او المعرف

$from_id تعني ايدي المستخدم

$first_name تعني الاسم الاول للمستخدم

$last_name تعني الاسم الثاني للمستخدم

$chat_id تعني ايدي المحادثه التي يوجد فيها البوت

وهناك متغيرات اخرى ساقوم بارسالها لكم
$update = json_decode(file_get_contents('php://input'));
$message = $update->message;
$chat_id = $message->chat->id;
$text = $message->text;
$message_id = $update->callback_query->message->message_id;
$data = $update->callback_query->data;
$from_id = $message->from->id;
$username = $message ->from->username ;
هناك عمليه تقوم بها للربط بين توكن البوت ورابط الملف تسمى بـ Webhook توجد طرق عدّه لعمل الويبهوك هناك (بوتات لعمل الويبهوك او روابط مباشره او من خلال فكشن الاتصال اللذي يحتوي على ويبهوك تلقائي) مثل هذا -> اضغط هنا
وبما انو الفكشن اللي رسلته الكم يحتوي على ويبهوك تلقائي مجرد الضغط على كلمه view في الاستضافه
لكن للتنبيه فقط او للمعلومه عن ضروره الويبهوك
لحد هنا دا تفتهمون لو اوضح اكثر؟
20 لايك اكمل شرح ♥️
شـروحات اساسيات لغه PHP
GIF
لاحض بالايقونات كلمه view اللي ضغطت عليها
وبهالطريقه انت سويت ويبهوك تلقائي
تمام نبدي نعيد كلشي بس ع شكل بصمه
حتى باختصار يصير
if($text == "/start"){
bot('sendMessage', [
'chat_id' =>$chat_id,
'text' =>"hello dear | مرحبا عزيزي",
]);
}


— — — — — — — — — — — — — — —

هذا هو الكود اضغط للنسخ
بعد ما تخلي فكشن الاتصال وتخلي متغيرات الملف
تنزل سطر وتخلي هذا الكود
كم شخص اشتغل عنده الكود
اشتغل ❤️
ما اشتغل 💔
<?php

ob_start();

define('API_KEY','توكن');
echo file_get_contents("https://api.telegram.org/bot" . API_KEY . "/setwebhook?url=" . $_SERVER['SERVER_NAME'] . "" . $_SERVER['SCRIPT_NAME']);
function bot($method,$datas=[]){
$url = "https://api.telegram.org/bot".API_KEY."/".$method;
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch,CURLOPT_POSTFIELDS,$datas);
$res = curl_exec($ch);
if(curl_error($ch)){
var_dump(curl_error($ch));
}else{
return json_decode($res);
}
}

$update = json_decode(file_get_contents('php://input'));
$message = $update->message;
$chat_id = $message->chat->id;
$text = $message->text;
$message_id = $update->callback_query->message->message_id;
$data = $update->callback_query->data;
$from_id = $message->from->id;
$username = $message ->from->username ;

if($text == "/start"){
bot('sendMessage', [
'chat_id' =>$chat_id,
'text' =>"hello dear | مرحبا عزيزي",
]);
}