我想从数据库中获取我的机器人消息并发送给用户,当我的文本只有1个单词时它工作,但现在它不起作用并显示HTTP BAD REQUEST 400.我想我应该使用curl,但我没有找不到任何对从电报机器人发送长消息有用的文件.(实际上因为我是php的初学者)
这是我的代码
$botToken="something";
$website="https://api.telegram.org/bot".$botToken;
$update = file_get_contents("php://input");
$update = json_decode($update, true);
$chatID = $update["message"]["chat"]["id"];
$message = $update["message"]["text"];
define("dbhost", "localhost:3306"); define("dbuser", "sm");
define("dbpass", "sm"); define("database", "sm");
switch ($message){
case "/get":
connected($chatID);
break;
}
function sendMessage($chatID,$message){
$url =$GLOBALS[website]."/sendMessage?chat_id=".$chatID."&text=".$message;
//file_get_contents($url);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
curl_close($ch);
//checkJSON($chatID,$update);
}
function connected($chatID){
$conn = mysql_connect(dbhost,dbuser,dbpass);
if(! $conn )
{
die('Could not connect: ' . mysqli_error());
}
mysql_select_db( database );
$strSQL = "SELECT text FROM bott …
Run Code Online (Sandbox Code Playgroud) 我想在我的Maven项目中使用休眠模式。我向资源中添加了hibernate.cfg.xml和hibernate.reveng.xml,还向pom.xml中添加了hibernate和oracle驱动程序,但是问题是它无法识别oracle驱动程序类。
这是输出
java.lang.ExceptionInInitializerError
at com.moshtagh.core.util.db.DataBase.<clinit>(DataBase.java:51)
at com.narmafzarsazan.peymane.model.AuthenticateModel.getWebUserByUserNameAndPassword(AuthenticateModel.java:35)
at com.narmafzarsazan.peymane.rs.AuthenticateRS.getText(AuthenticateRS.java:71)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(JavaMethodInvokerFactory.java:60)
at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$TypeOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:185)
at com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75)
at com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:288)
at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
at com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108)
at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
at com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84)
at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1469)
at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1400)
at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1349)
at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1339)
at com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:416)
at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:537)
at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:699)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449)
at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365)
at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)
at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)
at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:383)
at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362)
at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125) …
Run Code Online (Sandbox Code Playgroud)