pengrad / java-telegram-bot-api

Telegram Bot API for Java
https://core.telegram.org/bots
Apache License 2.0
1.81k stars 374 forks source link

please !!! #174

Closed SweetHomicide closed 5 years ago

SweetHomicide commented 5 years ago

I tried to build the bot connection and encountered this problem in all bot-api versions. 1.TelegramBot bot = new TelegramBot(botToken); javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target 2.When I use Override X509TrustManager;-------> OkHttpClient okHttpClient = new OkHttpClient.Builder().sslSocketFactory(createSSLSocketFactory()).hostnameVerifier(new TrustAllHostnameVerifier()).build(); TelegramBot bot = new TelegramBot.Builder(botToken).okHttpClient(okHttpClient).build(); // TelegramBot bot = new TelegramBot(botToken); //

    SendMessage request = new SendMessage("-344121375", "Testing ...")
            .parseMode(ParseMode.HTML)
            .disableWebPagePreview(true)
            .disableNotification(true)
            .replyToMessageId(1)
            .replyMarkup(new ForceReply());
    SendResponse sendResponse = bot.execute(request);
    boolean ok = sendResponse.isOk();
    Message message = sendResponse.message();
    System.out.println(ok);
    System.out.println("end");

SendResponse sendResponse = bot.execute(request);//return null??? conlose error : Exception in thread "main" java.lang.NullPointerException at com.bl.controllers.bot.telegram.TelegramMyBot.main(TelegramMyBot.java:63)

SweetHomicide commented 5 years ago

please help me ,sad....... - =!

pengrad commented 5 years ago

well, NullPointerException is quite clear, but only you can see where it happens, maybe you are using null message object which can return in case of unsuccessful request.