创建租赁
GET /api/rent_email.php?method=create_order
发送 GET 请求后,即使 HTTP 为 200,也请检查 status:1 成功,0 失败,创建租赁时的 2 表示暂无邮箱。错误详情可能在 msg、errormsg 和 errorid 中。
此请求可能修改租赁订单或产生费用。响应丢失后,先查询订单及历史,再决定是否重试:更改可能已经生效。示例不会自动重试。
身份验证
apikey 为必填查询参数。
参数
| 名称 | 位置 | 类型 | 必填 | 示例 | 说明 |
|---|---|---|---|---|---|
apikey | query | string | 是 | SMSPVA_API_KEY | 账户 API 密钥。读取邮件及管理租赁需要使用订单所属账户的密钥。 |
method | query | string | 是 | "create_order" | 要调用的方法。 |
scode | query | string | 是 | "twitter" | Services and Prices 返回的服务代码。 |
pcode | query | string | 否 | "outlookcom" | Get Providers 返回的供应商代码。接受全部供应商时完全省略此参数,不要传空值或 null。 |
dtype | query | string | 是 | "week" | 租赁单位:day = 1 天,week = 7 天,month = 30 天。 |
dcount | query | integer | 是 | 1 | 租赁周期数,必须为正数。 |
使用说明
为所选服务和时长租赁邮箱。scode 及当前价格见服务,pcode 见供应商。
接受任意供应商时,完全省略 pcode,不要发送 pcode=、空字符串或 null。指定供应商后,API 只会使用该供应商,即使无库存也不会自动更换。
租期为 dcount × 1、7 或 30 天,分别对应 day、week、month。费用按日价计算,30 天起适用 months_discount。status=2 表示没有可用邮箱,请先刷新余量再尝试。
将 data.id 保存为 orderid,同时保留邮箱地址、实际供应商和到期时间。用该 ID 读取邮件及查询有效订单。
请求示例
运行环境及依赖. 示例会对查询参数编码,最多等待 30 秒。使用 data 前请检查 HTTP 和 JSON status。cURL 输出原始响应供你检查,Java 使用 Jackson 读取 JSON。
设置 SMSPVA_EMAIL_PCODE 选择当前供应商;未设置或空值时完全省略 pcode。请使用实时列表中的代码。
SMSPVA_EMAIL_SCODE:scode.
provider_args=()
if [ -n "${SMSPVA_EMAIL_PCODE:-}" ]; then provider_args=(--data-urlencode "pcode=$SMSPVA_EMAIL_PCODE"); fi
: "${SMSPVA_API_KEY:?Set SMSPVA_API_KEY}"
: "${SMSPVA_EMAIL_SCODE:?Set SMSPVA_EMAIL_SCODE}"
curl --get --fail-with-body --max-time 30 "https://smspva.com/api/rent_email.php" \
--data-urlencode "method=create_order" \
--data-urlencode "apikey=$SMSPVA_API_KEY" \
"${provider_args[@]}" \
--data-urlencode "scode=$SMSPVA_EMAIL_SCODE" \
--data-urlencode "dtype=${SMSPVA_EMAIL_DTYPE:-week}" \
--data-urlencode "dcount=${SMSPVA_EMAIL_DCOUNT:-1}"响应
请查看与你的请求对应的响应。数值和日期仅供示例;可选字段可能因结果或所选响应格式而不同。
HTTP 200
HTTP 为 200 时仍需检查 status;示例数值仅供参考。
application/json
供应商不存在或已停用
{
"status": 0,
"errorid": 9,
"errormsg": "Provider not found",
"msg": "Provider not found"
}成功响应示例
{
"status": 1,
"data": {
"id": 123456,
"email": "[email protected]",
"scode": "twitter",
"pcode": "outlookcom",
"expireDate": 1855324800
}
}错误
{
"status": 0,
"msg": "Incorrect apikey"
}暂无可用邮箱
{
"status": 2
}成功
| 名称 | 类型 | 说明 |
|---|---|---|
status | integer | (enum: [1]) |
data | object | |
data.id | integer | 订单 ID,后续请求中作为 orderid 传入。 |
data.email | string | 分配的邮箱地址。 |
data.scode | string | 服务代码。 |
data.pcode | string | 实际分配的供应商代码。 |
data.expireDate | integer | 租赁到期时间,Unix 时间戳,单位为秒。 |
必填: status, data
暂无可用邮箱
| 名称 | 类型 | 说明 |
|---|---|---|
status | integer | (enum: [2]) |
必填: status
错误
部分错误含 errorid 和 errormsg,其他错误仅有 msg。请检查响应中提供的全部错误字段。
| 名称 | 类型 | 说明 |
|---|---|---|
status | integer | (enum: [0]) |
errorid | integer | 可选的结构化错误代码。 |
errormsg | string | 可选的错误说明。 |
msg | string | 错误信息。 |