Telegram-bot-sdk: I am totally new to Laravel

Created on 12 Jul 2015  路  10Comments  路  Source: irazasyed/telegram-bot-sdk

I am totally new to Laravel frame work ! I know this issue is because of that ! but PLZ help Me !
I do not know how to add this Packege in Providers ! Actually I have done steps and I have telegram.php in config folder now ! but I am getting this Err :

Undefined variable: telegram

while I want test my bot like this :
echo $response = $telegram->getMe();

Most helpful comment

I Found A solution !

It seems Err: " cURL error 60 " Is a Common Err Specially for Windows Users :
To solve the Err you need to do these steps :

  1. Download this file : http://curl.haxx.se/ca/cacert.pem and save it somewhere
  2. Update php.ini :add this Line curl.cainfo = "PATH_TO/cacert.pem"
  3. IMPORTANT NOTE: IF YOU ARE USING WAMP YOU HAVE 2 php.ini FILE YOU MUST CORRECT BOTH OF THEM FOR GETTING CORRECT RESULT :
    C:\wamp\bin\apacheApachex.x.x\binphp.ini
    C:\wamp\binphpphpx.x.xxphp.ini
  4. restart the apache server
    5.Enjoy Not getting Err

All 10 comments

No worries!

Did you add the facade ? If not just add it as that would be easier.

Once you do that. All you have to do is, make calls like for example:

$response = Telegram::getMe();

Then you can print the response.

Any method you want to use, You can use the facade. So instead of doing $telegram->getMe() you would prefix the methods with Telegram::.

If you don't want to use facade for whatever reasons. You can also access it like:

$response = app('telegram')->getMe();

But i would recommend you use Facade so it's much more cleaner and easier.

Thanks For Replying Back !

When I tried :

$resopnse = Telegram::getMe(); 

I got this error :

TelegramSDKException in GuzzleHttpClient.php line 97:
cURL error 60: SSL certificate problem: self signed certificate in certificate chain (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)

I have added these lines to My app.php plz check if Have added everything Ok or not :

{Providers}...

       /*
         * Application Service Providers...
         */
        App\Providers\AppServiceProvider::class,
        App\Providers\EventServiceProvider::class,
        App\Providers\RouteServiceProvider::class,

        Irazasyed\Telegram\Laravel\TelegramServiceProvider::class,

    ],

...
{aliases}...

       'Storage'   => Illuminate\Support\Facades\Storage::class,
        'URL'       => Illuminate\Support\Facades\URL::class,
        'Validator' => Illuminate\Support\Facades\Validator::class,
        'View'      => Illuminate\Support\Facades\View::class,

        'Telegram'  => Irazasyed\Telegram\Laravel\Facades\Telegram::class
    ],

THis is the detail of My Error : (May be Useful):

in GuzzleHttpClient.php line 97
at GuzzleHttpClient->send('https://api.telegram.org/<token>/getMe', 'GET', array('User-Agent' => 'Telegram Bot PHP SDK v0.2.2 - (https://github.com/irazasyed/telegram-bot-sdk)'), array('query' => array()), '60', false) in TelegramClient.php line 116

(Changed the Token in this comment)

Alright, Thanks for posting the error message.

I'll push an update today with a small change and it should resolve that error.

Also, Everything else is correct (Providers and Aliases)

Thank you Very Much..

waiting for Update ...

I Found A solution !

It seems Err: " cURL error 60 " Is a Common Err Specially for Windows Users :
To solve the Err you need to do these steps :

  1. Download this file : http://curl.haxx.se/ca/cacert.pem and save it somewhere
  2. Update php.ini :add this Line curl.cainfo = "PATH_TO/cacert.pem"
  3. IMPORTANT NOTE: IF YOU ARE USING WAMP YOU HAVE 2 php.ini FILE YOU MUST CORRECT BOTH OF THEM FOR GETTING CORRECT RESULT :
    C:\wamp\bin\apacheApachex.x.x\binphp.ini
    C:\wamp\binphpphpx.x.xxphp.ini
  4. restart the apache server
    5.Enjoy Not getting Err

Oh i see. Ok!

Guzzle cURL uses OS cert by default. Another insecure solution was to disable verify. Anyway, Thanks for sharing the solution. Maybe I'll disable verify or add a note for windows users.

Hi, I get this error Class 'App\Http\Controllers\Telegram' not found when i use the Telegram:: class

I have added Telegram as an alias in config

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jobs2008 picture jobs2008  路  3Comments

dswtech picture dswtech  路  4Comments

jahanzaibbahadur picture jahanzaibbahadur  路  4Comments

realtebo picture realtebo  路  4Comments

corneyl picture corneyl  路  3Comments