写点什么

秒验丨 REST API: 手机号码置换接口

  • 2023-07-13
    上海
  • 本文字数:2748 字

    阅读完需:约 9 分钟

功能说明

  • 提交客户端获取到的 token、opToken 等数据,验证后返回手机号码

调用地址

请求头
  • Content-Type :application/json

  • appkey:xxxxxxxxxx

入参说明


加密示例

  • 参数


"appkey" -> "2f2d7j9wf8a40""opToken" -> "f630dwff2f8f209c60a6449cf971ad50b3e83f4620a1536252457229836325""operator" -> "CUCC""token" -> "0:AAAAhAAAAIAIFOEDCVObiS1Pdyogg4JQw5Su4ce9rl/QVDaqKlcGDCzBssmrB3dYL3HcnNG9Gj7IzhiB/cRJF221cELTGHRiFGAjpGpjipkw/EbnoFuxjp3TPAhvprf/vqWm9dmUQCJ7P/+twKy5o5Y9XBBpD+W/jVPX/WbIQofYg3YGwAAAPDTY7g1X3rL326Dnlsifj/UDjoZ0Ftdh8qWG+ofn0P41bbO6q88id06vkU2x2eUEOb1RggqYt+BLHyG3PoLIC0AMGoUcTVyCcGYq15j+ZS23qiA2SLRYgwvvhD3N+HKTSWEPmYQDUKls5fckyQGW6x6yGB71NDUqwntBdQxwmT6W5NG379KyvPwRkZSN4cyJ29HugMMTx/0F9nF6YVgEogEHOms515lQ7f3TJqTidsVdIehQcDb2FdXnCJUjnOJTK4RWRHp9IvTxwXgmsT7WzkwWuSe/12sEx8Zdk2U66//nqgJ5c1FDbuHsqGlKA8fYyo=""timestamp" -> 1655190952281"appSecret" -> "9abee316611wd9ff607feb9f2c496338"
复制代码


  • 排序结果


appkey=2f2d7j9wf8a40&opToken=f630dwff2f8f209c60a6449cf971ad50b3e83f4620a1536252457229836325&operator=CUCC&timestamp=1655190952281&token=0:AAAAhAAAAIAIFOEDCVObiS1Pdyogg4JQw5Su4ce9rl/QVDaqKlcGDCzBssmrB3dYL3HcnNG9Gj7IzhiB/cRJF221cELTGHRiFGAjpGpjipkw/EbnoFuxjp3TPAhvprf/vqWm9dmUQCJ7P/+twKy5o5Y9XBBpD+W/jVPX/WbIQofYg3YGwAAAPDTY7g1X3rL326Dnlsifj/UDjoZ0Ftdh8qWG+ofn0P41bbO6q88id06vkU2x2eUEOb1RggqYt+BLHyG3PoLIC0AMGoUcTVyCcGYq15j+ZS23qiA2SLRYgwvvhD3N+HKTSWEPmYQDUKls5fckyQGW6x6yGB71NDUqwntBdQxwmT6W5NG379KyvPwRkZSN4cyJ29HugMMTx/0F9nF6YVgEogEHOms515lQ7f3TJqTidsVdIehQcDb2FdXnCJUjnOJTK4RWRHp9IvTxwXgmsT7WzkwWuSe/12sEx8Zdk2U66//nqgJ5c1FDbuHsqGlKA8fYyo=
复制代码


  • 拼接 appSecret


appkey=2f2d7j9wf8a40&opToken=f630dwff2f8f209c60a6449cf971ad50b3e83f4620a1536252457229836325&operator=CUCC×tamp=1655190952281&token=0:AAAAhAAAAIAIFOEDCVObiS1Pdyogg4JQw5Su4ce9rl/QVDaqKlcGDCzBssmrB3dYL3HcnNG9Gj7IzhiB/cRJF221cELTGHRiFGAjpGpjipkw/EbnoFuxjp3TPAhvprf/vqWm9dmUQCJ7P/+twKy5o5Y9XBBpD+W/jVPX/WbIQofYg3YGwAAAPDTY7g1X3rL326Dnlsifj/UDjoZ0Ftdh8qWG+ofn0P41bbO6q88id06vkU2x2eUEOb1RggqYt+BLHyG3PoLIC0AMGoUcTVyCcGYq15j+ZS23qiA2SLRYgwvvhD3N+HKTSWEPmYQDUKls5fckyQGW6x6yGB71NDUqwntBdQxwmT6W5NG379KyvPwRkZSN4cyJ29HugMMTx/0F9nF6YVgEogEHOms515lQ7f3TJqTidsVdIehQcDb2FdXnCJUjnOJTK4RWRHp9IvTxwXgmsT7WzkwWuSe/12sEx8Zdk2U66//nqgJ5c1FDbuHsqGlKA8fYyo=9abee316611wd9ff607feb9f2c496338
复制代码


  • 计算 MD5 结果


sign -> 3f1991b27b1c86a32e661eabdd3d1f5a
复制代码

请求示例

curl --location --request POST 'http://identify.verify.mob.com/auth/auth/sdkClientFreeLogin' \--header 'Content-Type: application/json' \--data-raw '{"token":"0:AAAAhAAAAIAIJn3PvTUUJ94umGqPmZCFtprF5Pg7uCxb+Opp+JtZrHIX3yxVOGEHJQLHuRLU1hlTbYyxCMfW53fuck6OL1X+01qdf+NpTVj1ApmQzapKWFB3DEPNNdyad8HwxZY/ZGWcch0Njy+Pb0TgqMwAytBWKu5vlvN9LRoWw/6F3K4BGgAAAPDHlbG1uFKewi7J1g3d6tAor/kIHG0A8csscrESYVfmVYzB6RBfQWfwDpZIYLrXOuSFdWP3bqKbEyIiqvSeY3ktxSus2lUdD6MzwYo1aXJ6oALEW/A07Qx5/3S6ClSmtGrHuzDnC6JCsmHEQWR7S2wNLSojS95Zd91AC2gpqV5tmKEaVGDc827JVEHXFX6Zr5d0pNmBHLS0b67BrNfG4v0qSgcf/OL3a1xOQVieqUDbrAPiNF7Q2wifCbj0FQyIt5+LPpOkqKDbYff21WinJMTOuOMoJcqOhrI1gUEmnHE/ZU8ZZXN52Kffd+Pk7aR7MMU=","opToken":"a53c2dc92083cb1375218a0f1dd35e0050bb26e40ba0a1536204920384995379", "appkey": "2f2d7a68f8a40", "operator": "CUCC",  "sign": "576ec00ac6ad80a2d0a92872d748e82b", "timestamp": 1655094782181}'
复制代码

响应示例

  • 请求成功


{    "error": null,    "res": "ZfukzNuB5oKbxBKxK9MoYFzr1IDZ0Z/i+xLYyq/JCAmi24DPYHdGeUqxE6OjQuP3VY1c76CyfoU=",    "seqid": "456484936150429696",    "status": 200}
复制代码


  • 请求失败


{    "status": 4119342,    "res": null,    "error": "签名错误",    "seqid": "null"}
复制代码


  • 响应参数


数据解密

返回体中的 res 数据需要使用 appSecet 解密

解密方式

DES/CBC/PKCS5Padding


偏移量 00000000


使用 base64 转码

字段说明
{       "isValid":1,     "phone": "13888888888",    "valid":"true"}
复制代码



示例代码

Java


import java.security.Key;import java.security.spec.AlgorithmParameterSpec;
import javax.crypto.Cipher;import javax.crypto.SecretKey;import javax.crypto.SecretKeyFactory;import javax.crypto.spec.DESKeySpec;import javax.crypto.spec.IvParameterSpec;
public class DES {
public static final String ALGORITHM = "DES"; public static final String PADDING = "DES/CBC/PKCS5Padding"; private static final byte[] DEFAULT_INITIALIZATION_VECTOR = ("00000000".getBytes());
private String padding = PADDING; private AlgorithmParameterSpec paramSpec;
public DES(String padding, byte[] initializationVectorBytes) { this.padding = padding; this.paramSpec = new IvParameterSpec(initializationVectorBytes); }
public byte[] decodeBytes(byte[] data, byte[] key) throws Exception { Key secretKey = getKey(key); Cipher cipher = Cipher.getInstance(padding); cipher.init(Cipher.DECRYPT_MODE, secretKey, paramSpec); return cipher.doFinal(data);
}
private static Key getKey(byte[] key) throws Exception { DESKeySpec dks = new DESKeySpec(key); SecretKeyFactory keyFactory = SecretKeyFactory.getInstance(ALGORITHM); SecretKey secretKey = keyFactory.generateSecret(dks); return secretKey; }
public static byte[] decode(byte[] data, byte[] key) throws Exception { return decode(data, key, DEFAULT_INITIALIZATION_VECTOR); }
public static byte[] decode(byte[] data, byte[] key, byte[] ivBytes) throws Exception { DES des = new DES(PADDING, ivBytes); return des.decodeBytes(data, key); }
}
复制代码


import java.util.Base64;
public abstract class Base64Utils {
public Base64Utils() { }
public static byte[] decode(byte[] src) { return src.length == 0 ? src : Base64.getDecoder().decode(src); }
}
复制代码

返回码


发布于: 刚刚阅读数: 5
用户头像

还未添加个人签名 2019-05-08 加入

还未添加个人简介

评论

发布
暂无评论
秒验丨 REST API:手机号码置换接口_大数据_MobTech袤博科技_InfoQ写作社区