Validate.php
1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<?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)
{
try {
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]);
}
}catch (\Exception $e){
return [];
}
return Arr::s2a($res);
}
}