Validate.php 1.6 KB
<?php


namespace App\Helper;

use App\Utils\HttpUtils;
use GuzzleHttp\Exception\GuzzleException;


/**
 * Class Validate
 * @package App\Helper
 * @author zbj
 * @date 2025/2/27
 */
class Validate
{
    /**
     * 邮箱有效性
     * @param $email
     * @return bool
     * @author zbj
     * @date 2025/2/27
     */
    public static function email($email)
    {
        try {
            $res = HttpUtils::get('https://fob.ai.cc/api/check_email', ['email' => $email]);
            $res = Arr::s2a($res);
            $status = $res['data']['status'] ?? 0;
        } catch (\Exception | GuzzleException $e) {
            $status = 0;
        }
        return !($status == 2);
    }

    /**
     * 邮箱有效性
     * @param $email
     * @return bool
     * @author zbj
     * @date 2025/2/27
     */
    public static function phone($phone)
    {
        try {
            $res = HttpUtils::get('https://fob.ai.cc/api/check_phone', ['phone' => $phone]);
            $res = Arr::s2a($res);
            $status = $res['data']['valid_status'] ?? 0;
        } catch (\Exception | GuzzleException $e) {
            $status = 0;
        }
        return !($status == 2);
    }

    /**
     * @remark :验证
     * @name   :check_data
     * @author :lyh
     * @method :post
     * @time   :2025/3/4 17:16
     */
    public static function check_data($data,$type)
    {
        if($type == 1){
            $res = HttpUtils::get('https://fob.ai.cc/api/check_email', ['email' => $data]);
        }else{
            $res = HttpUtils::get('https://fob.ai.cc/api/check_phone', ['phone' => $data]);
        }
        return Arr::s2a($res);
    }
}