اقا چرا من هر کاری می کنم درست نمیشه
لطفا ببنید کارها رو درست انجام داده ام
1- یک ربات در botfather ایجاد کردم
2- یک ssl برای دامنه گرفتم و به دامنه افزودم
3- دامنه با https به خوبی بالا میاد
4- فایل bot.php رو با همون فرمت نوشته شده نوشتم
5- لینک ست کردم Webhook رو اجرا کردم و در نتیجه نوشت
{"ok":true,"result":true,"description":"Webhook is set"}
اما هر چی ربات رو اجرا می کنم هیچ عکس العملی نداره ...
یکی راهنمایی کنه مشکل از کجاست
این هم لینک ربات
@t2255776bot
ممنون از توجه شما دوست عزیز
این خطایی که تو error log وجود داره
[04-Mar-2016 21:03:14 Asia/Tehran] PHP Warning: file_get_contents() [<a href='function.file-get-contents'>function.file-get-contents</a>]: https:// wrapper is disabled in the server configuration by allow_url_fopen=0 in /home/samankar/public_html/hamdelbot.com/bot.php on line 27
[04-Mar-2016 21:03:14 Asia/Tehran] PHP Warning: file_get_contents(https://api.telegram.org/bot20568916...;text=پيام شما دريافت شد.) [<a href='function.file-get-contents'>function.file-get-contents</a>]: failed to open stream: no suitable wrapper could be found in /home/samankar/public_html/hamdelbot.com/bot.php on line 27
البته من با یک تابع چک کرده بودم که این تابع روی سرور باز هست اما این خطا رو داده
ایا راه دیگری برای این کار است
باز هم ممنون
از این کد استفاده کردم
اما با زهم خطا داد این هم متن خطا$token = '';
$url = 'https://api.telegram.org/bot'.$token.'/sendMessage';
$ch = curl_init( );
curl_setopt( $ch, CURLOPT_URL, $url );
curl_setopt( $ch, CURLOPT_POST, 1 );
curl_setopt( $ch, CURLOPT_POSTFIELDS, "text=".$text_reply ."&chat_id=".$user_id );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $ch, CURLOPT_TIMEOUT, 500 );
$agent = $_SERVER["HTTP_USER_AGENT"];
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$check = curl_exec( $ch );
Mar-2016 21:23:45 Asia/Tehran] PHP Warning: curl_setopt() [<a
href='function.curl-setopt'>function.curl-setopt</a>]:
CURLOPT_FOLLOWLOCATION cannot be activated when safe_mode is
با اعمال کد شما هیچ خطایی داده نشد
اما جوابی هم نیامد
میشه بفرمایید الان بااین کد چه کاری انجام میشه
این هم کد کامل ما
<
$token = 'tttttt';
$text_reply='سلام';
$url = 'https://api.telegram.org/bot'.$token.'/sendMessage';
$ch = curl_init( );
curl_setopt( $ch, CURLOPT_URL, $url );
curl_setopt( $ch, CURLOPT_POST, 1 );
curl_setopt( $ch, CURLOPT_POSTFIELDS, "text=".$text_reply ."&chat_id=".$user_id );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $ch, CURLOPT_TIMEOUT, 500 );
$agent = $_SERVER["HTTP_USER_AGENT"];
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
$check = curl_exec( $ch );
ویرایش توسط mohammad-gh : March 4th, 2016 در ساعت 21:58
متد ارسال مسیج هست. که پیام سلام را به مقدار $user_id ارسال میکند.
پیام در متغییر $text_reply قرار میگیرد. آیدی گیرنده در متغییر $user_id و مقدار توکن ربات هم در متغییر $token.
با این کدخطایی داده نشد اما همچنان جواب هم نمیادکد PHP:
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
راستی من دستور نوشتن تو فایل رو هم که گفته بودید زدم کنار دستورات کا اون کار میکنه و معلومه فقط این کدها یه جایی مشکل دارن
باز هم کدها رو میزارم لطفا ببنیید جایی مشکل داره
کد PHP:
$token = 'ففففففففففففففففففف';
$url = 'https://api.telegram.org/bot'.$token.'/sendMessage';
$ch = curl_init( );
curl_setopt( $ch, CURLOPT_URL, $url );
curl_setopt( $ch, CURLOPT_POST, 1 );
if($text == 'سلام')
$text_reply = 'سلام';
if($text == 'اسم تون')
$text_reply = 'ربات تست';
if($text == 'خوبي؟')
$text_reply = 'ممنون';
curl_setopt( $ch, CURLOPT_POSTFIELDS, "text=".$text_reply ."&chat_id=".$user_id );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $ch, CURLOPT_TIMEOUT, 500 );
$agent = $_SERVER["HTTP_USER_AGENT"];
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
$check = curl_exec( $ch );
در حال حاضر 1 کاربر در حال مشاهده این موضوع است. (0 کاربران و 1 مهمان ها)