简体   繁体   English

使用Twilio的REST API

[英]Using the REST API of Twilio

Not being familiar with REST and after reading some doc about it I am a little bit confused about the way it works. 不熟悉REST,在阅读了有关它的文档后,我对它的工作方式有些困惑。

I actually want to use Twilio SMS Gateway that provides a REST API to interact with and send text messages from an existing web-application. 我实际上想使用Twilio SMS网关,该网关提供REST API与现有的Web应用程序进行交互并从中发送文本消息。

From what I understand, REST is a way to structure a web service and in the end, instead of using SOAP for example, we just access 'resources' with URLs, relying on HTTP to GET, PUT or DELETE data. 据我了解,REST是一种构建Web服务的方法,最后,例如,我们仅使用URL访问“资源”,而不是使用SOAP,而是依靠HTTP来访问GET,PUT或DELETE数据。

The SMS Gateway I am talking about is providing a Java API that I could integrate to my web-app. 我正在谈论的SMS网关提供了一个Java API,可以将其集成到我的Web应用程序中。 The classes in this API uses httpcore, httpclient and commons-codec jars. 此API中的类使用httpcore,httpclient和commons编解码器jar。 Is this because REST rely on HTTP? 这是因为REST依赖HTTP吗?

So basically, their API is relying on the Apache and HTTP libs to construct HTTP requests in Java and setting the basics, so I just have to provide with the data I want to submit and/or specific information? 因此,基本上,他们的API依靠Apache和HTTP库在Java中构造HTTP请求并设置基础,因此我只需要提供要提交的数据和/或特定信息?

REST API's are HTTP API's. REST API是HTTP API。 The word REST is supposed to indicate something about how your API works. REST这个词应该表示有关您的API如何工作的信息。 Basically that you use POST requests to update data and GET requests to retrieve it, and you have different HTTP endpoints for all of the different resources in your API, like Calls or Recordings. 基本上,您使用POST请求来更新数据,而使用GET请求来检索数据,并且对于API中的所有不同资源(例如,调用或录音),您具有不同的HTTP端点。

The Twilio helper libraries (including the Java library) are basically wrappers around HTTP calls to the Twilio API. Twilio帮助器库(包括Java库)基本上是对Twilio API的HTTP调用的包装。 The idea was to make it easier for you to make API calls to Twilio by abstracting away the HTTP authentication and request stuff behind some more language-specific code. 这样做的目的是通过简化HTTP身份验证并在一些特定于语言的代码后面请求内容,使您更轻松地对Twilio进行API调用。 We also parse the HTTP response into an object for you. 我们还将HTTP响应解析为一个对象。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM