通过 Java 在 RingCentral 中发送和接收短信

Send and Receive sms through Java in RingCentral

我对 ringcentral API 很陌生,目前正在浏览所有这些。

目前正在浏览以下参考文献:https://developers.ringcentral.com/api-reference/SMS/createSMSMessage

通过Java我们可以使用API发送短信,但是我们可以使用Java接收短信吗?

有人可以帮助我获得 documentation/article 或任何类型的 reference 我可以在那里了解简单的使用 Java

发送和接收短信的方式

这是一条短信 Java 快速入门指南:https://developers.ringcentral.com/guide/sms/quick-start/java

希望对您有所帮助!

这里是官方的RingCentral Java SDK:https://github.com/ringcentral/ringcentral-java,目前是1.0.0-beta9。我们将在本月发布稳定版本。

以下是您可以调用的所有 API 调用的列表:https://github.com/ringcentral/ringcentral-java/blob/master/samples.md, including sms sending: https://github.com/ringcentral/ringcentral-java/blob/master/samples.md#create-smsmms-message

对于短信接收,您可以使用我们的订阅和通知功能:https://github.com/ringcentral/ringcentral-java#pubnub-subscriptions--notificatioins 所以每当有新短信时,您都会收到通知,然后您可以发出 api 电话以获取消息。

有关技术细节,您可以随时发送电子邮件至 devsupport@ringcentral.com

使用 Java 发送短信的示例如下:

import java.io.IOException;
import com.ringcentral.*;
import com.ringcentral.definitions.*;

public class Send_SMS {
    String RECIPIENT_NUMBER = "<ENTER PHONE NUMBER>";
    String RINGCENTRAL_CLIENTID = "<ENTER CLIENT ID>";
    String RINGCENTRAL_CLIENTSECRET = "<ENTER CLIENT SECRET>";

    String RINGCENTRAL_USERNAME = "<YOUR ACCOUNT PHONE NUMBER>";
    String RINGCENTRAL_PASSWORD = "<YOUR ACCOUNT PASSWORD>";
    String RINGCENTRAL_EXTENSION = "<YOUR EXTENSION, PROBABLY ";

    public static void main(String[] args) {
      var obj = new Send_SMS();
            try {
          obj.sendSms();
            } catch (RestException | IOException e) {
                e.printStackTrace();
            }
    }

    public void sendSms() throws RestException, IOException{
      RestClient rc = new RestClient(RINGCENTRAL_CLIENTID, RINGCENTRAL_CLIENTSECRET, RINGCENTRAL_SERVER);
      rc.authorize(RINGCENTRAL_USERNAME, RINGCENTRAL_EXTENSION, RINGCENTRAL_PASSWORD);

      CreateSMSMessage postParameters = new CreateSMSMessage();
      postParameters.from = new MessageStoreCallerInfoRequest().phoneNumber(RINGCENTRAL_USERNAME);
      postParameters.to = new MessageStoreCallerInfoRequest[]{new MessageStoreCallerInfoRequest().phoneNumber(RECIPIENT_NUMBER)};
      postParameters.text = "Hello World from Java";

      var response = rc.restapi().account().extension().sms().post(postParameters);
      System.out.println("SMS sent. Message status: " + response.messageStatus);
    }
}

您可以从这里下载 java SDKhttps://github.com/ringcentral/ringcentral-java
并从此处的文档开始:https://developers.ringcentral.com/guide/messaging/quick-start/java
在您的应用程序中获得 后,您可以开始编译它并 运行 它。