php-telegram-bot / core

PHP Telegram Bot based on the official Telegram Bot API
MIT License
3.87k stars 951 forks source link

getUpdateCLI.php - SSL certificate problem: self signed certificate in certificate chain #49

Closed farhadsaberi closed 8 years ago

farhadsaberi commented 8 years ago

Hi, i used getUpdate Method and when opened getUpdateCLI.php , bot does not reply to me , i get this error:

exception 'Longman\TelegramBot\Exception\TelegramException' with message 'SSL certificate problem: self signed certificate in certificate chain' in C:\xampp\htdocs\Longman\TelegramBot\src\Request.php:161 Stack trace: #0 C:\xampp\htdocs\Longman\TelegramBot\src\Request.php(239): Longman\TelegramBot\Request::executeCurl('getUpdates', Array) #1 C:\xampp\htdocs\Longman\TelegramBot\src\Request.php(394): Longman\TelegramBot\Request::send('getUpdates', Array) #2 C:\xampp\htdocs\Longman\TelegramBot\src\Telegram.php(364): Longman\TelegramBot\Request::getUpdates(Array) #3 C:\xampp\htdocs\Longman\TelegramBot\example-getUpdatesCLI.php(42): Longman\TelegramBot\Telegram->handleGetUpdates() #4 {main}

This is my getUpdateCLI.php:

<?php

bash script

while true; do ./getUpdatesCLI.php; done

//Composer Loader $loader = require DIR.'/vendor/autoload.php';

$API_KEY = 'xxxxx'; $BOT_NAME = 'xxxxx'; // $COMMANDS_FOLDER = DIR.'/Commands/'; $credentials = array('host'=>'localhost:3306', 'user'=>'root', 'password'=>'XXXXX', 'database'=>'dbname');

try { // create Telegram API object $telegram = new Longman\TelegramBot\Telegram($API_KEY, $BOT_NAME); $telegram->enableMySQL($credentials); $telegram->handleGetUpdates();

//Options // $telegram->enableMySQL($credentials, $BOTNAME.''); // $telegram->addCommandsPath($COMMANDS_FOLDER); //here you can set some command specified parameters, //for example, google geocode/timezone api key for date command: // $telegram->setCommandConfig('date', array('google_api_key'=>'your_google_api_key_here')); //$telegram->setLogRequests(true); //$telegram->setLogPath($BOT_NAME.'.log'); //$telegram->setLogVerbosity(3); //$telegram->setDownloadPath("../Download"); //$telegram->setUploadPath("../Upload"); // $results = $telegram->sendToActiveChats( // 'sendMessage', //callback function to execute (see Request.php methods) // array('text'=>'Hey! Checkout the new feature!!'), //Param to evaluate the request // true, //Send to chats (group chat) // true, //Send to users (single chat) // null, //'yyyy-mm-dd hh:mm:ss' date range from // null //'yyyy-mm-dd hh:mm:ss' date range to // ); // $results = $telegram->handle(); // handle telegram getUpdate request } catch (Longman\TelegramBot\Exception\TelegramException $e) { // log telegram errors echo $e; }

MBoretto commented 8 years ago

Did you upload certificate? Maybe this can help you http://snippets.webaware.com.au/howto/stop-turning-off-curlopt_ssl_verifypeer-and-fix-your-php-config/

farhadsaberi commented 8 years ago

Yes, tnx Bro.

MohMaz commented 8 years ago

Hi! I have read the article you provided and set my cainfo path as: curl.cainfo = "D:/Program Files/wamp/bin/php/cacert.pem But I still get the same error when I try to run getUpdatesCLI.php example. I use Apache/2.4.9 (Win64) PHP/5.5.12! Any idea what else should I check?

Thank you.

Fixed

I was modifying wrong php.ini file :-)