抖音开放平台Logo
开发者文档
“/”唤起搜索
控制台

获取用户手机号

收藏
我的收藏
该接口在用户公开信息的基础上,额外获取用户的手机号。
    Scope: mobile_alert

接口说明

注意
能力改造中,暂不开放申请,详情请参考平台公告

前提条件

请先获取用户公开信息,才能获取用户手机号。

注意事项

    解密手机号,使用 AES 算法解密,密钥是 client_secret, 向量 lv 是 client_secret 前 16 字节。
    通过辅助手机号绑定的信息不会返回。

示例解密代码

Java
PHP
Golang
import javax.crypto.Cipher; import javax.crypto.SecretKey; import javax.crypto.spec.SecretKeySpec; import javax.crypto.spec.IvParameterSpec; import java.util.Base64; import java.util.Arrays; import java.security.InvalidAlgorithmParameterException; import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; import java.security.spec.InvalidKeySpecException; import javax.crypto.NoSuchPaddingException; import javax.crypto.IllegalBlockSizeException; import javax.crypto.BadPaddingException; public class DecryptMobile{ public static String decrypt(String algorithm, String cipherText, SecretKey key,IvParameterSpec iv) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException, IllegalBlockSizeException, BadPaddingException { Cipher cipher = Cipher.getInstance(algorithm); cipher.init(Cipher.DECRYPT_MODE, key, iv); byte[] plainText = cipher.doFinal(Base64.getDecoder().decode(cipherText)); return new String(plainText); } public static void main(String []args) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException, IllegalBlockSizeException, BadPaddingException { String clientSecret = "0123456789abcdef0123456789abcdef"; String encryptedMobile = "tyUWQwYuUmVFJtElAL+D7Q=="; byte[] clientSecretBytes = clientSecret.getBytes(); SecretKey secretKey = new SecretKeySpec(clientSecretBytes, 0, clientSecretBytes.length, "AES"); byte[] iv = Arrays.copyOfRange(clientSecretBytes, 0, 16); IvParameterSpec ivParameterSpec = new IvParameterSpec(iv); String algorithm = "AES/CBC/PKCS5Padding"; String mobile = decrypt(algorithm, encryptedMobile, secretKey, ivParameterSpec); System.out.println(mobile); } }