3
Plivo SMS APIとJava Webアプリケーションを統合しています。私は自分のアプリケーションを通してメッセージを送信したい。私はhttps://www.plivo.com/docs/getting-started/send-a-single-sms/リンクを参照しています。以下 は、コードスニペットです:Plivo SMSが送信されておらず、Javaでエラーが発生しています
String authId = "{my Auth_id}"; //Your Authentication ID
String authToken = "{my auth Token}"; //Your authentication code
RestAPI api = new RestAPI(authId, authToken, "v1");
LinkedHashMap<String, String> parameters = new LinkedHashMap<String, String>();
parameters.put("src", "+44*******"); // Sender's phone number with country code
parameters.put("dst", "+91*******"); // Receiver's phone number with country code
parameters.put("text", "Hi, text from Plivo"); // Your SMS text message
try {
// Send the message
MessageResponse msgResponse = api.sendMessage(parameters);
// Print the response
System.out.println(msgResponse);
// Print the Api ID
System.out.println("Api ID : " + msgResponse.apiId);
// Print the Response Message
System.out.println("Message : " + msgResponse.message);
if (msgResponse.serverCode == 202) {
// Print the Message UUID
System.out.println("Message UUID : " + msgResponse.messageUuids.get(0).toString());
} else {
System.out.println(msgResponse.error);
}
} catch (PlivoException e) {
System.out.println(e.getLocalizedMessage());
}
私はコンソールアプリケーションを使用してこのコードを実行しようとしただけでなく、ウェブapplication.Iは例外取得しています「com.plivo.helper.exception.PlivoExceptionを:https://api.plivo.comへの接続を拒否しました」。私のコードで何が間違っていますか?ここに何もないのですか?
ファイアウォールの設定がトラフィックをブロックしていないことを確認してください。また、Webプロキシを使用していますか?はいの場合、アプリケーションがこのプロキシを使用して接続を処理していることを確認します。 –
はい、プロキシ設定の問題があり、何とかAPIへの接続をブロックしていました。私は私のプロキシ設定を変更し、それは働き始めた。ご協力ありがとうございました! – Manushi
素晴らしい!質問に回答してください。 –