PHP Mã Code Check Yahoo Tồn Tại Hoặc Chưa Tồn Tại

CÁCH DÙNG
Tạo một file php bất kỳ, ví dụ: “index.php”
Truy cập: <tên miền của bạn>/index.php?email=<địa chỉ yahoo>, ví dụ: domain.com/[email protected]

 

 

<?php

error_reporting(0);
session_start();
date_default_timezone_set("Asia/Ho_Chi_Minh");


$email   = isset($_GET['email']) ? $_GET['email'] : NULL;
$domains = [
    'yahoo.com'
];
if (filter_var($email, FILTER_VALIDATE_EMAIL) === FALSE)
{
    $response = [
        'status' => 'error',
        'message' => 'Email không hợp lệ'
    ];
    echo json_encode($response);
    exit;
}

$domain = explode('@', $email)[1];
$user   = explode('@', $email)[0];

if (!in_array($domain, $domains))
{
    $response = [
        'status' => 'error',
        'message' => 'Email không hỗ trợ'
    ];
    echo json_encode($response);
    exit;
}
$get     = getUrl();
$cookies = explode('set-cookie: ', $get);
preg_match('/<input type="hidden" value="([^"]+)" name="crumb">/', $get, $matches);
$crumb = $matches[1];
preg_match('/<input type="hidden" value="([^"]+)" name="acrumb">/', $get, $matches);
$acrumb = $matches[1];
preg_match('/<input type="hidden" value="([^"]+)" name="sessionIndex">/', $get, $matches);
$sessionIndex = $matches[1];

if (count($cookies) < 1)
{
    $response = [
        'status' => 'error',
        'message' => 'Hiện tại hệ thống đang bận, vui lòng thử lại sau'
    ];
    echo json_encode($response);
    exit;
}
foreach ($cookies as $cookie)
{
    $arr[] = explode(';', $cookie)[0];
}
array_shift($arr);
$cookie = implode('; ', $arr);

$dataArr = array(
    "browser-fp-data" => '{"language":"en-US","colorDepth":24,"deviceMemory":8,"pixelRatio":1,"hardwareConcurrency":32,"timezoneOffset":-420,"timezone":"Asia/Saigon","sessionStorage":1,"localStorage":1,"indexedDb":1,"cpuClass":"unknown","platform":"Win32","doNotTrack":"unknown","plugins":{"count":5,"hash":"2c14024bf8584c3f7f63f24ea490e812"},"canvas":"canvas winding:yes~canvas","webgl":1,"webglVendorAndRenderer":"Google Inc. (NVIDIA)~ANGLE (NVIDIA, NVIDIA GeForce RTX 2060 (0x00001E89) Direct3D11 vs_5_0 ps_5_0, D3D11)","adBlock":0,"hasLiedLanguages":0,"hasLiedResolution":0,"hasLiedOs":0,"hasLiedBrowser":0,"touchSupport":{"points":0,"event":0,"start":0},"fonts":{"count":50,"hash":"0e5070720b4f8461727bc707c4499d96"},"audio":"124.04347527516074","resolution":{"w":"2560","h":"1440"},"availableResolution":{"w":"1392","h":"2560"},"ts":{"serve":1724046813828,"render":1724046813708}}',
    "specId" => "yidregsimplified",
    "context" => "REGISTRATION",
    "cacheStored" => "",
    "crumb" => $crumb,
    "acrumb" => $acrumb,
    "sessionIndex" => $sessionIndex,
    "done" => "https://www.yahoo.com",
    "googleIdToken" => "",
    "authCode" => "",
    "attrSetIndex" => "0",
    "specData" => "",
    "tos0" => "oath_freereg|vn|vi-VN",
    "multiDomain" => "",
    "firstName" => "",
    "lastName" => "",
    "userid-domain" => "yahoo",
    "userId" => $user,
    "password" => "",
    "mm" => "",
    "dd" => "",
    "yyyy" => "",
    "signup" => ""
);

$post1     = postUrl(http_build_query($dataArr), $cookie);
$post2     = json_decode($post1);
$error_msg = [];

foreach ($post2->errors as $error)
{
    if ($error->name == 'userId')
    {
        $error_msg[] = $error->error;
    }
}

if (in_array('IDENTIFIER_NOT_AVAILABLE', $error_msg))
{
    $response = [
        'status' => 'notavailable',
    ];
    echo json_encode($response);
    exit;
}
else
{
    $response = [
        'status' => 'available',
    ];
    echo json_encode($response);
    exit;
}

function postUrl ($postdata, $cookie)
{
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, 'https://login.yahoo.com/account/module/create?validateField=userId');
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
    curl_setopt($ch, CURLOPT_HTTPHEADER, [
        'accept: */*',
        'accept-language: en',
        'content-type: application/x-www-form-urlencoded; charset=UTF-8',
        'cookie: ' . $cookie,
        'origin: https://login.yahoo.com',
        'priority: u=1, i',
        'referer: https://login.yahoo.com/account/create',
        'user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36',
        'x-requested-with: XMLHttpRequest'
    ]);
    $data = curl_exec($ch);
    curl_close($ch);
    return $data;
}

function getUrl ()
{
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, 'https://login.yahoo.com/account/create');
    curl_setopt($ch, CURLOPT_HEADER, 1);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
    $data = curl_exec($ch);
    curl_close($ch);
    return $data;
}

?>