gpt4 book ai didi

java - 使用 twilio : The API package 'urlfetch' or call 'Fetch()' was not found 发送短信

转载 作者:行者123 更新时间:2023-11-29 04:48:14 25 4
gpt4 key购买 nike

我正在运行这段代码:

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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com