Akbarali
Shaxsan o`zim telegram botda php curldan emas Guzzle, PHP HTTP client da yozishni boshladim. Tezligi ancha yaxshi bo`lar ekan.
Guzledagi botga namuna:
  1. <?php
  2. require_once( 'vendor/autoload.php' );
  3. use GuzzleHttp\Client;
  4. $apiKey = '<TOKEN>'; // Put your bot's API key here
  5. $apiURL = 'https://api.telegram.org/bot' . $apiKey . '/';
  6. $client = new Client( array( 'base_uri' => $apiURL ) );
  7. $update = json_decode(file_get_contents( 'php://input' ) );
  8.  
  9. $chatid = $update->message->chat->id;
  10. $type = $update->message->chat->type;
  11. $lastname = $update->message->chat->last_name;
  12. $fristname = $update->message->chat->first_name;
  13. $keyboard2 = json_encode(['inline_keyboard' => [[['url' => 'https://t.me/convertor_group', 'text' => 'Guruhga qo`shilish'], ], [['url' => 'https://uzhackersw.uz/', 'text' => 'Saytga kirish'], ], ], ]);
  14. $keyboard = json_encode(['inline_keyboard' => [[['url' => 'https://t.me/convertor_group', 'text' => 'Guruhimiz'], ], [['url' => 'https://uzhackersw.uz/', 'text' => 'Saytga kirish'], ], ], ]);
  15. $akbarali = '<ADMIN_ID>';
  16. $guruhim = '<CHAT_ID>';
  17.  
  18. if ( $update->message->text == 'Hello' ){
  19. $client->post( 'sendChatAction', array( 'query' => array( 'chat_id' => $chatid, 'action' => "typing" ) ) );
  20. $client->post( 'sendMessage', array( 'query' => array( 'chat_id' => $chatid, 'text' => "Bu Guzledan yuborilgan xabar" ) ) );
  21.  
  22. }
  23.  
  24. if ( $update->message->text == 'file' ){
  25. $client->post( 'sendChatAction', array( 'query' => array( 'chat_id' => $chatid, 'action' => "upload_video" ) ) );
  26. $client->post( 'sendDocument', array( 'query' => array( 'chat_id' => $chatid, 'document' => "https://uzfor.uz/view.php?act=file&id=2472" ) ) );
  27.  
  28. }
  29.  
  30.  
  31. if ( $update->message->text == '/start' ){
  32. $client->post( 'sendMessage', array( 'query' => array(
  33. 'chat_id' => $chatid,
  34. 'text' => "Salom " . $fristname. " " .$lastname . ". Men JPG rasmni PDF qilish sizga tashlash uchun @kbarali tomonidan yozildim. Menga rasm tashlashdan oldin /boshla buyrug`ini bering. Keyin JPG rasmni PHOTO qilish tashlang (file qilib emas)!", 'parse_mode' => 'html', 'reply_markup' => $keyboard2)));
  35. }