使用轻识AI智能搜索

轻识AI

API REFERENCE

共 8983字,需浏览 18分钟

 ·

2023-04-25 13:42

common

host

https://uni.apistd.com

public parameters

Public parameters are the parameters that must be carried when calling the API request, and are uniformly transmitted using the URL Query parameter.

nametyperequireddescriptionexample
actionstringtrueinterface namesms.message.send
accessKeyIdstringtrueAccessKey IDrQJEk4mz6gZzTC9X8XHfpQ1Vt

access authentication

UniSMS provides the following two authentication methods for developers to choose from, which can be set in the 「console-Certificate Management」, and the default is simple mode.

  • simple mode [default]:This mode only verifies the AccessKey ID and does not verify the signature of the request parameters, which is convenient for developers to access quickly.
  • HMAC mode:This mode need AccessKey Secret to verify the request parameters to strengthen the security and authenticity of the request.

simple mode

Use the simple mode to complete the access authentication, just pass the AccessKey ID value obtained from the console-credential management to the URL Query parameter accessKeyId to complete the authentication.

HMAC mode

To complete access authentication using the HMAC mode, all URL Query parameters need to be arranged in dictionary order as the text string to be signed, and signed according to the specified signature hash algorithm.

Add the required public parameters (Query) as follows:

nametyperequireddescriptionexample
algorithmstringtrueSignature hash algorithm, currently only supports hmac-sha256hmac-sha256
timestampnumbertrueTimestamp (ms), accepted tolerance time 10 minutes1620243278785
noncestringtrueRandom string, between 8-64 charactersd7041f4746a09b10
signaturestringtruesignxvv9UjzOrQFWe7fFS5IUU9iqIZrncvF093SqXsnfcK8=
Signature generation step

1. Extract all URL Query parameter pairs in the request, and sort them in lexicographical order (positive order) according to the parameter Key,use = join Key-Value,use & joinare paired to form the text string to be signed, as shown in the following example:

accessKeyId=rQJEk4mz6gZzTC9X8XHfpQ1Vt&action=sms.message.send&algorithm=hmac-sha256&nonce=d7041f4746a09b10×tamp=1620269782258

2. use HmacSHA256 algorithm,use AccessKey ID corresponding AccessKey Secret as key,generate a signature for the "text to be signed",output Base64 (或 Hex) string,as shown in the following example:

xvv9UjzOrQFWe7fFS5IUU9iqIZrncvF093SqXsnfcK8=

3.Add the signature string as the value of signature to the query parameter of the request URL to send the request. The final complete request URL example is as follows:

https://uni.apistd.com/?action=sms.message.send&accessKeyId=rQJEk4mz6gZzTC9X8XHfpQ1Vt&algorithm=hmac-sha256×tamp=1620269782258&nonce=d7041f4746a09b10&signature=xvv9UjzOrQFWe7fFS5IUU9iqIZrncvF093SqXsnfcK8%3D


Send message

Use this interface to send a text message to one or more recipients. Please read the common before reading this document.

inteface

  • name:sms.message.send
  • HTTP Method:POST
  • Content-Type:application/json

Request Data

nametyperequireddescriptionexample
tostring | string[]truephone number, use E.164 format+8618688061234
signaturestringtruesignature,between 2-16 charactersUniSMS
contentstringfalsemessage context,templateId or content choose oneyour verification code is 9153,Valid for 15 minutes.
templateIdstringfalseSMS templateId or templateId templateCode,templateId or content choose onelogin_notify
templateDataJSONfalse-{"code": "9153", "ttl": "15"}

* Note: In order to help developers migrate quickly, UniSMS supports the use of the content parameter to directly pass in text, and new access users are recommended to use templateId to pass parameters first

Request Example

curl -X POST 'https://uni.apistd.com/?action=sms.message.send&accessKeyId=YOUR_ACCESS_KEY_ID' \
-H 'Content-Type: application/json' \
-d '{
  "to": "+861860571xxxx",
  "signature": "UniSms",
  "templateId": "signup",
  "templateData": {"code": "3241", "ttl": "10"}
}'

response

nametypedescriptionexample
codestringbusiness code105400
messagestringbusiness messageInsufficientFunds
dataJSONbusiness result

response.data

nametypedescriptionexample
statusstring-sent
recipientsinteger-1
messageCountintegerif context too long, may be split1
totalAmountnumber-0.045
payAmountnumber-0.045
virtualAmountnumber-0
messagesJSON[]-⬇️

response.data.messages

nametypedescriptionexample
idstringidentity7cf4b5c12c5ad49379ce07290d9b00bb
tostringphone number (E.164)+8618688061234
regionCodestring-CN
countryCodestring-86
messageCountinteger-1
statusstring-sent
upstreamstringreal upstreamemay.standard
pricestring-0.040000

Response Example

Success

Status Code: 200, Response Body:

{
  "code": "0",
  "message": "Success",
  "data": {
    "recipients": 2,
    "messageCount": 2,
    "totalAmount": "0.187500",
    "payAmount": "0.187500",
    "virtualAmount": "0",
    "messages": [
      {
        "id": "4e88293e50aac21d027a9d6c0f33661e",
        "to": "+8618688061234",
        "regionCode": "CN",
        "countryCode": "86",
        "messageCount": 1,
        "status": "sent",
        "upstream": "emay.standard",
        "price": "0.050000"
      },
      {
        "id": "ce02a6c4195c6f8c4b6a7250ccb3b0a1",
        "to": "+12894260331",
        "regionCode": "CA",
        "countryCode": "1",
        "messageCount": 1,
        "status": "sent",
        "upstream": "emay.intl.standard",
        "price": "0.137500"
      }
    ]
  }
}

Error

Status Code: 400, Response Body:

{
  "code": "105400",
  "message": "InsufficientFunds"
}


Voice verification code

Use this interface to send a voice verification code (to make a call) to a recipient. Read API Common before reading this document.

inteface

  • name:sms.voice.verification.send
  • HTTP Method:POST
  • Content-Type:application/json

Request

nametyperequireddescriptionexample
tostringtruephone number+8618509872103
codestringtruebetween 2-16 characters5201

* Note: The use of international mobile phone numbers is not supported at the moment

Example

curl -X POST 'https://uni.apistd.com/?action=sms.voice.verification.send&accessKeyId=YOUR_ACCESS_KEY_ID' \
-H 'Content-Type: application/json' \
-d '{
  "to": "+861850987xxxx",
  "code": "5201"
}'

Response

nametypeexample
codestring101301
messagestringNoUpstreamAvailable
dataJSON⬇️

Response.data

nametypeexample
statusstringsent
recipientsinteger1
messageCountinteger1
totalAmountnumber0.05
payAmountnumber0.05
messagesJSON[]

Response.data.messages

nametypedescriptionexample
idstringmessage identy7086bf2f0c2e944b15b08897277d8414
tostringphone number (E.164)+8618509872103
regionCodestring-CN
countryCodestring-86
messageCountintegerif context too long, may be split1
statusstring-sent
upstreamstring-monyun.standard
pricestring-0.050000

Response

when success

Status Code: 200, Response Body:

{
  "data": {
    "recipients": 1,
    "messageCount": 1,
    "totalAmount": "0.050000",
    "payAmount": "0.050000",
    "virtualAmount": "0",
    "messages": [
      {
        "id": "7086bf2f0c2e944b15b08897277d8414",
        "to": "+8618509872103",
        "regionCode": "CN",
        "countryCode": "86",
        "messageCount": 1,
        "status": "sent",
        "upstream": "monyun.standard",
        "price": "0.050000"
      }
    ]
  },
  "code": "0",
  "message": "Success"
}

when error

Status Code: 400, Response Body:

{
  "code": "101303",
  "message": "NoUpstreamAvailable"
}


Error code and description

codedescriptionexplanation
0OkRequest success
101000InternalInner error
101301NoUpstreamConfiguredNo valid upstream channel set. Please check whether the expert mode is turned on and the channel configuration is not completed, you can switch to the fusion mode to quickly solve the problem
101303NoUpstreamAvailableAll upstream channels failed, indicating that the request has no available upstreams
104001MissingParams-
104002InvalidParams-
104003RestrictedParams-
104110MissingAccessKeyId-
104111InvalidAccessKeyId-
104201InvalidSignaturePlease refer to API Common to generate a request signature
104202InvalidSignatureTimestampPlease check that the value passed in is a valid UNIX timestamp, a difference of 10 minutes from the server time is acceptable
105001Unauthorized-
105100IpRestrictedPlease check whether the IP restriction extension service is enabled, and make sure that the request server IP matches the configuration
105300LimitExceedPlease check whether the sending frequency limit extension service is enabled, and if necessary, you can adjust the limit upper limit by yourself
105400InsufficientFunds-
107111InvalidPhoneNumbers-
107120MissingSmsSignature-
107121SmsSignatureNotExistsPlease visit the control panel to add
107122InvalidSmsSignatureThe signature has not been approved or is currently under review
107123RestrictedSmsSignaturePlease contact your Account Manager to find out if there are negotiation restrictions
107141SmsTemplateNotExistsPlease visit the control panel to add. If you are using a review-free template that starts with pub_, please check whether the template code is correct
107143MissingSmsTemplateData-
107144InvaildSmsTemplateData-
107145RestrictedSmsTemplatePlease contact your Account Manager to find out if there are negotiation restrictions


浏览 8
点赞
评论
收藏
分享

手机扫一扫分享

分享
举报
评论
图片
表情
推荐
点赞
评论
收藏
分享

手机扫一扫分享

分享
举报