Как получить идентификатор сообщения для общедоступного почтового ящика Mailinator с помощью команды CurlJAVA

Программисты JAVA общаются здесь
Ответить Пред. темаСлед. тема
Anonymous
 Как получить идентификатор сообщения для общедоступного почтового ящика Mailinator с помощью команды Curl

Сообщение Anonymous »


I have been trying with curl command to get the message id for public account in mailinator.

But i think there is some issue, as i am getting the html response, and no details are there for inbox messages. I am not sure what wrong i am doing, none of the below command has worked.

curl -x GET https://www.mailinator.com/v3/inbox.jsp?to=test11 -H 'Content-Type: application/json' -H 'Accept: application/json' curl -x GET "https://mailinator.com/api/v3/domains/p ... ?to=test11" Gone through mailinator apis, but clear information is not there, also wathed few youtube videos still unable to find any relevant information. Tried with below command and java code.

`curl -x GET "https://mailinator.com/api/v2/domains/p ... ?to=test11"

curl -x GET "https://mailinator.com/ws/fetchpublic/a ... ?to=test11"`
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL; import org.json.JSONArray; import org.json.JSONObject; public class MailinatorPublicAccountExample { public static void main(String[] args) { String publicAccount = "test11"; try { // Create the API URL String apiUrl = String.format("https://www.mailinator.com/v3/inbox.jsp?to=%s", publicAccount); // Send GET request to the API URL url = new URL(apiUrl); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.setRequestMethod("GET"); // Get the API response BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream())); String line; StringBuilder response = new StringBuilder(); while ((line = reader.readLine()) != null) { response.append(line); } reader.close(); // Process the response JSONArray messages = new JSONArray(response.toString()); for (int i = 0; i < messages.length(); i++) { JSONObject message = messages.getJSONObject(i); String messageId = message.getString("id"); String messageBody = fetchMessageBody(messageId); System.out.println("Message ID: " + messageId); System.out.println("Message Body: " + messageBody); System.out.println("--------------------------------------"); } // Close the connection connection.disconnect(); } catch (IOException e) { e.printStackTrace(); } } private static String fetchMessageBody(String messageId) throws IOException { // Create the API URL for fetching message body String apiUrl = String.format("https://api.mailinator.com/v3/domains/m ... es/%s/body", messageId); // Send GET request to the API URL url = new URL(apiUrl); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.setRequestMethod("GET"); // Get the API response BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream())); String line; StringBuilder response = new StringBuilder(); while ((line = reader.readLine()) != null) { response.append(line); } reader.close(); // Close the connection connection.disconnect(); return response.toString(); } }

Источник: https://stackoverflow.com/questions/764 ... rl-command
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение

Вернуться в «JAVA»