作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在运行这段代码:
ACCOUNT_SID, AUTH_TOKEN
= 来 self 的账户
public static void main(String[] args) throws TwilioRestException {
TwilioRestClient client = new TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN);
Account account = client.getAccount();
MessageFactory messageFactory = account.getMessageFactory();
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("To", ...my number...));
params.add(new BasicNameValuePair("From", ...my twilio number..));
params.add(new BasicNameValuePair("Body", "Where's Wallace?"));
Message sms = messageFactory.create(params);
String a = "1";
}
但是在运行messageFactory.create
时得到这个异常
我已经跑了:
mvn appengine:devserver
知道如何解决这个问题吗?
java.lang.reflect.InvocationTargetException
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:483)
at com.twilio.sdk.AppEngineClientConnection.flush(AppEngineClientConnection.java:197)
at org.apache.http.protocol.HttpRequestExecutor.doSendRequest(HttpRequestExecutor.java:258)
at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:123)
at org.apache.http.impl.client.DefaultRequestDirector.tryExecute(DefaultRequestDirector.java:645)
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:464)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:820)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:754)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:732)
at com.twilio.sdk.TwilioRestClient.request(TwilioRestClient.java:410)
at com.twilio.sdk.TwilioRestClient.safeRequest(TwilioRestClient.java:581)
at com.twilio.sdk.resource.list.MessageList.create(MessageList.java:70)
at com.waze.beacon.inline.server.services.SmsSenderImp.main(SmsSenderImp.java:33)
Caused by: com.google.apphosting.api.ApiProxy$CallNotFoundException: The API package 'urlfetch' or call 'Fetch()' was not found.
at com.google.apphosting.api.ApiProxy.makeSyncCall(ApiProxy.java:111)
at com.google.appengine.api.urlfetch.URLFetchServiceImpl.fetch(URLFetchServiceImpl.java:38)
... 16 more
Apr 01, 2016 10:07:51 PM org.apache.http.impl.client.DefaultRequestDirector tryExecute
INFO: I/O exception (java.io.IOException) caught when processing request: Error flushing content in Google App Engine fetch
Apr 01, 2016 10:07:51 PM org.apache.http.impl.client.DefaultRequestDirector tryExecute
INFO: Retrying request
java.lang.reflect.InvocationTargetException
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:483)
at com.twilio.sdk.AppEngineClientConnection.flush(AppEngineClientConnection.java:197)
at org.apache.http.protocol.HttpRequestExecutor.doSendRequest(HttpRequestExecutor.java:258)
at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:123)
at org.apache.http.impl.client.DefaultRequestDirector.tryExecute(DefaultRequestDirector.java:645)
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:464)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:820)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:754)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:732)
at com.twilio.sdk.TwilioRestClient.request(TwilioRestClient.java:410)
at com.twilio.sdk.TwilioRestClient.safeRequest(TwilioRestClient.java:581)
at com.twilio.sdk.resource.list.MessageList.create(MessageList.java:70)
at com.waze.beacon.inline.server.services.SmsSenderImp.main(SmsSenderImp.java:33)
Caused by: com.google.apphosting.api.ApiProxy$CallNotFoundException: The API package 'urlfetch' or call 'Fetch()' was not found.
at com.google.apphosting.api.ApiProxy.makeSyncCall(ApiProxy.java:111)
at com.google.appengine.api.urlfetch.URLFetchServiceImpl.fetch(URLFetchServiceImpl.java:38)
... 16 more
Apr 01, 2016 10:07:51 PM org.apache.http.impl.client.DefaultRequestDirector tryExecute
INFO: I/O exception (java.io.IOException) caught when processing request: Error flushing content in Google App Engine fetch
Apr 01, 2016 10:07:51 PM org.apache.http.impl.client.DefaultRequestDirector tryExecute
INFO: Retrying request
java.lang.reflect.InvocationTargetException
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:483)
at com.twilio.sdk.AppEngineClientConnection.flush(AppEngineClientConnection.java:197)
at org.apache.http.protocol.HttpRequestExecutor.doSendRequest(HttpRequestExecutor.java:258)
at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:123)
at org.apache.http.impl.client.DefaultRequestDirector.tryExecute(DefaultRequestDirector.java:645)
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:464)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:820)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:754)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:732)
at com.twilio.sdk.TwilioRestClient.request(TwilioRestClient.java:410)
at com.twilio.sdk.TwilioRestClient.safeRequest(TwilioRestClient.java:581)
at com.twilio.sdk.resource.list.MessageList.create(MessageList.java:70)
at com.waze.beacon.inline.server.services.SmsSenderImp.main(SmsSenderImp.java:33)
Caused by: com.google.apphosting.api.ApiProxy$CallNotFoundException: The API package 'urlfetch' or call 'Fetch()' was not found.
at com.google.apphosting.api.ApiProxy.makeSyncCall(ApiProxy.java:111)
at com.google.appengine.api.urlfetch.URLFetchServiceImpl.fetch(URLFetchServiceImpl.java:38)
... 16 more
Apr 01, 2016 10:07:51 PM org.apache.http.impl.client.DefaultRequestDirector tryExecute
INFO: I/O exception (java.io.IOException) caught when processing request: Error flushing content in Google App Engine fetch
Apr 01, 2016 10:07:51 PM org.apache.http.impl.client.DefaultRequestDirector tryExecute
INFO: Retrying request
java.lang.reflect.InvocationTargetException
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:483)
at com.twilio.sdk.AppEngineClientConnection.flush(AppEngineClientConnection.java:197)
at org.apache.http.protocol.HttpRequestExecutor.doSendRequest(HttpRequestExecutor.java:258)
at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:123)
at org.apache.http.impl.client.DefaultRequestDirector.tryExecute(DefaultRequestDirector.java:645)
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:464)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:820)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:754)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:732)
at com.twilio.sdk.TwilioRestClient.request(TwilioRestClient.java:410)
at com.twilio.sdk.TwilioRestClient.safeRequest(TwilioRestClient.java:581)
at com.twilio.sdk.resource.list.MessageList.create(MessageList.java:70)
at com.waze.beacon.inline.server.services.SmsSenderImp.main(SmsSenderImp.java:33)
Caused by: com.google.apphosting.api.ApiProxy$CallNotFoundException: The API package 'urlfetch' or call 'Fetch()' was not found.
at com.google.apphosting.api.ApiProxy.makeSyncCall(ApiProxy.java:111)
at com.google.appengine.api.urlfetch.URLFetchServiceImpl.fetch(URLFetchServiceImpl.java:38)
... 16 more
Exception in thread "main" java.lang.RuntimeException: java.io.IOException: Error flushing content in Google App Engine fetch
at com.twilio.sdk.TwilioRestClient.request(TwilioRestClient.java:437)
at com.twilio.sdk.TwilioRestClient.safeRequest(TwilioRestClient.java:581)
at com.twilio.sdk.resource.list.MessageList.create(MessageList.java:70)
at com.waze.beacon.inline.server.services.SmsSenderImp.main(SmsSenderImp.java:33)
Caused by: java.io.IOException: Error flushing content in Google App Engine fetch
at com.twilio.sdk.AppEngineClientConnection.flush(AppEngineClientConnection.java:201)
at org.apache.http.protocol.HttpRequestExecutor.doSendRequest(HttpRequestExecutor.java:258)
at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:123)
at org.apache.http.impl.client.DefaultRequestDirector.tryExecute(DefaultRequestDirector.java:645)
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:464)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:820)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:754)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:732)
at com.twilio.sdk.TwilioRestClient.request(TwilioRestClient.java:410)
... 3 more
Disconnected from the target VM, address: '127.0.0.1:61151', transport: 'socket'
Process finished with exit code 1
最佳答案
这里有个问题似乎很相似:getting strange exception trying to implement asynchronous http in google app engine for java
根据@Antony 接受的答案,问题是这些 API 在本地开发服务器中不可用,但在 Google App Engine 中部署时会可用。
关于java - 使用 twilio : The API package 'urlfetch' or call 'Fetch()' was not found 发送短信,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36364359/
我是一名优秀的程序员,十分优秀!