PDA

View Full Version : مبتدی: مشکل در ربات تلگرام



taj3da
سه شنبه 26 دی 1396, 19:14 عصر
سلام از روی آموزش دارم ربات مینویسم ولی برای من خطا میده

کد صفحه index


<?php


require ('config.php');
require ('telegram.php');


$db=mysqli_connect('localhost','khazarne_khandeh', '******;4','khazarne_khandeh_bazar');
$query=mysqli_query($db,"select * from joke order by rand() limit 1");


$telegram = new telegram(token);




//echo $telegram->getme();


//echo $telegram->getupdates();


//دریافت اطلاعات ارسال شده به بات و تبدیل به آرایه
$result=$telegram->reciveText();


$userid=$result->message->from->id;
$text=$result->message->text;






/// ارسال پیام کاربر به خودش
//$telegram->sendmessage($userid,$text);


if($text=="/sendjoke")
{


$telegram->sendmessage($userid,$query);
}


کد صفحه telegram



<?php


class telegram {






/// دریافت اطلاعات بات
public function getme()
{
$url='https://api.telegram.org/bot541992420******w/getMe';
return file_get_contents($url);
}

/// دریافت اطلاعات ارسال شده به بات

public function getupdates()
{
$url='https://api.telegram.org/bot541992420:AAF******eNw/getupdates';
return file_get_contents($url);
}

public function reciveText()
{
$text=json_decode(file_get_contents('php://input'));
return $text;
}



public function sendmessage($userid,$text)
{
$url='https://api.telegram.org/bot54199242********/sendmessage?chat_id='.$userid.'&text='.$text;
file_get_contents($url);
}
}




اینم خطا


[16-Jan-2018 19:47:41 Asia/Tehran] PHP Catchable fatal error: Object of class mysqli_result could not be converted to string in /home/khazarne/public_html/bt/telegram.php on line 33
[16-Jan-2018 19:47:42 Asia/Tehran] PHP Catchable fatal error: Object of class mysqli_result could not be converted to string in /home/khazarne/public_html/bt/telegram.php on line 33