同款下载

解析123网盘链接 – PHP代码分享


图片[1]-解析123网盘链接 - PHP代码分享

将下面代码新建成index.php保存即可。

<!DOCTYPE html>
<html>
<head>
<title>123解析</title>
<style>
body {
font-family: "Helvetica Neue", Arial, sans-serif;
background-color: #f5f5f7;
margin: 0;
padding: 0;
display: flex;
align-items: center;
justify-content: center;
min-height: 100vh;
}
.container {
max-width: 600px;
padding: 20px;
box-sizing: border-box;
text-align: center;
}
h1 {
font-size: 32px;
font-weight: bold;
color: #333333;
margin-bottom: 40px;
margin-top: 40px;
}
form {
margin-bottom: 40px;
}
label {
display: block;
font-size: 20px;
font-weight: bold;
color: #333333;
margin-bottom: 10px;
}
input[type="text"] {
width: 100%;
padding: 12px;
font-size: 16px;
border: 1px solid #cccccc;
box-sizing: border-box;
margin-bottom: 20px;
}
input[type="submit"] {
padding: 12px 24px;
font-size: 18px;
font-weight: bold;
color: #ffffff;
background-color: #0070c9;
border: none;
cursor: pointer;
}
.download-link {
margin-top: 20px;
display: flex;
align-items: center;
justify-content: center;
}
.error-icon {
margin-right: 10px;
color: #ff0000;
font-size: 24px;
}
.success-icon {
margin-right: 10px;
color: #009900;
font-size: 24px;
}
a {
display: inline-block;
padding: 12px 24px;
font-size: 18px;
font-weight: bold;
color: #ffffff;
background-color: #0070c9;
text-decoration: none;
}
a:hover {
background-color: #0057a0;
}
</style>
</head>
<body>
<div class="container">
<h1>123解析</h1>
<form method="post" action="">
<label for="shareUrl">分享链接:</label>
<input type="text" id="shareUrl" name="shareUrl" required>
<input type="submit" name="submit" value="解析">
</form>
<?php if(isset($_POST['submit']) && isset($redirectUrl)): ?>
<?php endif; ?>
<?php
if(isset($_POST['submit'])) {
$shareUrl = $_POST['shareUrl'];
$shareCode = "";
$pattern = "/(?<=\/s\/)[^\/.]+/";
preg_match($pattern, $shareUrl, $match);
if ($match) {
$shareId = $match[0];
$extractCodePattern = "/提取码:(\w+)/";
preg_match($extractCodePattern, $shareUrl, $extractCodeMatch);
if ($extractCodeMatch) {
$shareCode = $extractCodeMatch[1];
}
// Get user information
getInfo($shareId, $shareCode);
} else {
echo'<span class="error-icon">✗</span>'. "错误: 123pan URL 未找到!";
}
}
function getInfo($shareId, $shareCode) {
$requestUrl = "https://www.123pan.com/b/api/share/get?limit=100&next=1&orderBy=share_id&orderDirection=desc&shareKey=" . $shareId . "&SharePwd=" . $shareCode . "&ParentFileId=0&Page=1";
$opts = array(
'http' => array(
'header' => "User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36 Edg/109.0.1518.100\r\n"
)
);
$context = stream_context_create($opts);
$responseText = file_get_contents($requestUrl, false, $context);
parseInfo($responseText, $shareId);
}
function parseInfo($str, $shareId) {
$data = json_decode($str, true);
if ($data['code'] == 0) {
$type = $data['data']['InfoList'][0]['Type'];
if ($type == 0) {
$fileId = $data['data']['InfoList'][0]['FileId'];
$size = $data['data']['InfoList'][0]['Size'];
$s3KeyFlag = $data['data']['InfoList'][0]['S3KeyFlag'];
$etag = $data['data']['InfoList'][0]['Etag'];
// Perform second step
combinedData($shareId, $fileId, $size, $s3KeyFlag, $etag);
} else {
echo "错误: Folder parsing is currently not supported.";
}
} else {
$code = $data['code'];
$message = $data['message'];
echo '<span class="error-icon">✗</span>'."错误: 错误码" . $code . "//" . $message;
}
}
function combinedData($shareId, $fileId, $size, $s3KeyFlag, $etag) {
$requestUrl = "https://www.123pan.com/b/api/share/download/info";
$postData = json_encode(array(
"ShareKey" => $shareId,
"FileID" => $fileId,
"S3keyFlag" => $s3KeyFlag,
"Size" => $size,
"Etag" => $etag
));
$opts = array(
'http' => array(
'header' => "User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36 Edg/109.0.1518.100\r\n" .
"Content-Type: application/json;charset=UTF-8\r\n",
'method' => 'POST',
'content' => $postData
)
);
$context = stream_context_create($opts);
$response = file_get_contents($requestUrl, false, $context);
parseDownloadURL($response);
}
function parseDownloadURL($str) {
$data = json_decode($str, true);
if ($data['code'] == 0) {
$downloadURL = $data['data']['DownloadURL'];
$downloadURL = extractDownloadLink($downloadURL);
getDirectLink($downloadURL);
} else {
$code = $data['code'];
$message = $data['message'];
echo '<span class="error-icon">✗</span>'."错误: 错误码" . $code . "//" . $message;
}
}
function extractDownloadLink($str) {
$pattern = "/params=([^&]+)/";
preg_match($pattern, $str, $match);
if ($match) {
$paramsValue = $match[1];
$decodedString = base64_decode($paramsValue);
// Check if auto_redirect parameter exists
if (strpos($decodedString, 'auto_redirect') === false) {
if (strpos($decodedString, '?') !== false) {
$decodedString .= "&auto_redirect=0";
} else {
$decodedString .= "?auto_redirect=0";
}
}
return $decodedString;
} else {
echo "Failed to extract Download URL";
}
}
function getDirectLink($requestUrl) {
$opts = array(
'http' => array(
'header' => "User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36 Edg/109.0.1518.100\r\n"
)
);
$context = stream_context_create($opts);
$responseText = file_get_contents($requestUrl, false, $context);
parseDirectLink($responseText);
}
function parseDirectLink($str) {
$data = json_decode($str, true);
if ($data['code'] == 0) {
$redirectUrl = $data['data']['redirect_url'];
echo '<span class="success-icon">✓</span><a href="' . $redirectUrl . '">点击下载</a>';
} else {
$code = $data['code'];
$message = $data['message'];
echo '<span class="error-icon">✗</span>'."错误: 错误码" . $code . "//" . $message;
}
}
?>
</div>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
    <title>123解析</title>
    <style>
        body {
            font-family: "Helvetica Neue", Arial, sans-serif;
            background-color: #f5f5f7;
            margin: 0;
            padding: 0;
            display: flex;
            align-items: center;
            justify-content: center;
            min-height: 100vh;
        }

        .container {
            max-width: 600px;
            padding: 20px;
            box-sizing: border-box;
            text-align: center;
        }

        h1 {
            font-size: 32px;
            font-weight: bold;
            color: #333333;
            margin-bottom: 40px;
            margin-top: 40px;
        }

        form {
            margin-bottom: 40px;
        }

        label {
            display: block;
            font-size: 20px;
            font-weight: bold;
            color: #333333;
            margin-bottom: 10px;
        }

        input[type="text"] {
            width: 100%;
            padding: 12px;
            font-size: 16px;
            border: 1px solid #cccccc;
            box-sizing: border-box;
            margin-bottom: 20px;
        }

        input[type="submit"] {
            padding: 12px 24px;
            font-size: 18px;
            font-weight: bold;
            color: #ffffff;
            background-color: #0070c9;
            border: none;
            cursor: pointer;
        }

        .download-link {
            margin-top: 20px;
            display: flex;
            align-items: center;
            justify-content: center;
        }
      

        .error-icon {
            margin-right: 10px;
            color: #ff0000;
            font-size: 24px;
        }

        .success-icon {
            margin-right: 10px;
            color: #009900;
            font-size: 24px;
        }

        a {
            display: inline-block;
            padding: 12px 24px;
            font-size: 18px;
            font-weight: bold;
            color: #ffffff;
            background-color: #0070c9;
            text-decoration: none;
        }

        a:hover {
            background-color: #0057a0;
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>123解析</h1>
        <form method="post" action="">
            <label for="shareUrl">分享链接:</label>
            <input type="text" id="shareUrl" name="shareUrl" required>
            <input type="submit" name="submit" value="解析">
        </form>

        <?php if(isset($_POST['submit']) && isset($redirectUrl)): ?>
            
        <?php endif; ?>






<?php
if(isset($_POST['submit'])) {
    $shareUrl = $_POST['shareUrl'];
    $shareCode = "";
    $pattern = "/(?<=\/s\/)[^\/.]+/";
    preg_match($pattern, $shareUrl, $match);

    if ($match) {
        $shareId = $match[0];
        $extractCodePattern = "/提取码:(\w+)/";
        preg_match($extractCodePattern, $shareUrl, $extractCodeMatch);

        if ($extractCodeMatch) {
            $shareCode = $extractCodeMatch[1];
        }

        // Get user information
        getInfo($shareId, $shareCode);
    } else {
        echo'<span class="error-icon">✗</span>'. "错误: 123pan URL 未找到!";
    }
}

function getInfo($shareId, $shareCode) {
    $requestUrl = "https://www.123pan.com/b/api/share/get?limit=100&next=1&orderBy=share_id&orderDirection=desc&shareKey=" . $shareId . "&SharePwd=" . $shareCode . "&ParentFileId=0&Page=1";
    $opts = array(
        'http' => array(
            'header' => "User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36 Edg/109.0.1518.100\r\n"
        )
    );
    $context = stream_context_create($opts);
    $responseText = file_get_contents($requestUrl, false, $context);

    parseInfo($responseText, $shareId);
}

function parseInfo($str, $shareId) {
    $data = json_decode($str, true);

    if ($data['code'] == 0) {
        $type = $data['data']['InfoList'][0]['Type'];

        if ($type == 0) {
            $fileId = $data['data']['InfoList'][0]['FileId'];
            $size = $data['data']['InfoList'][0]['Size'];
            $s3KeyFlag = $data['data']['InfoList'][0]['S3KeyFlag'];
            $etag = $data['data']['InfoList'][0]['Etag'];

            // Perform second step
            combinedData($shareId, $fileId, $size, $s3KeyFlag, $etag);
        } else {
            echo "错误: Folder parsing is currently not supported.";
        }
    } else {
        $code = $data['code'];
        $message = $data['message'];
        echo '<span class="error-icon">✗</span>'."错误: 错误码" . $code . "//" . $message;
    }
}

function combinedData($shareId, $fileId, $size, $s3KeyFlag, $etag) {
    $requestUrl = "https://www.123pan.com/b/api/share/download/info";
    $postData = json_encode(array(
        "ShareKey" => $shareId,
        "FileID" => $fileId,
        "S3keyFlag" => $s3KeyFlag,
        "Size" => $size,
        "Etag" => $etag
    ));

    $opts = array(
        'http' => array(
            'header' => "User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36 Edg/109.0.1518.100\r\n" .
                        "Content-Type: application/json;charset=UTF-8\r\n",
            'method' => 'POST',
            'content' => $postData
        )
    );
    $context = stream_context_create($opts);
    $response = file_get_contents($requestUrl, false, $context);

    parseDownloadURL($response);
}

function parseDownloadURL($str) {
    $data = json_decode($str, true);

    if ($data['code'] == 0) {
        $downloadURL = $data['data']['DownloadURL'];
        $downloadURL = extractDownloadLink($downloadURL);
        getDirectLink($downloadURL);
    } else {
        $code = $data['code'];
        $message = $data['message'];
        echo '<span class="error-icon">✗</span>'."错误: 错误码" . $code . "//" . $message;
    }
}

function extractDownloadLink($str) {
    $pattern = "/params=([^&]+)/";
    preg_match($pattern, $str, $match);

    if ($match) {
        $paramsValue = $match[1];
        $decodedString = base64_decode($paramsValue);

        // Check if auto_redirect parameter exists
        if (strpos($decodedString, 'auto_redirect') === false) {
            if (strpos($decodedString, '?') !== false) {
                $decodedString .= "&auto_redirect=0";
            } else {
                $decodedString .= "?auto_redirect=0";
            }
        }

        return $decodedString;
    } else {
        echo "Failed to extract Download URL";
    }
}

function getDirectLink($requestUrl) {
    $opts = array(
        'http' => array(
            'header' => "User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36 Edg/109.0.1518.100\r\n"
        )
    );
    $context = stream_context_create($opts);
    $responseText = file_get_contents($requestUrl, false, $context);

    parseDirectLink($responseText);
}

function parseDirectLink($str) {
    $data = json_decode($str, true);

    if ($data['code'] == 0) {
        $redirectUrl = $data['data']['redirect_url'];
         echo '<span class="success-icon">✓</span><a href="' . $redirectUrl . '">点击下载</a>';
    } else {
        $code = $data['code'];
        $message = $data['message'];
        echo '<span class="error-icon">✗</span>'."错误: 错误码" . $code . "//" . $message;
    }
}
?>
    </div>
</body>
</html>

<!DOCTYPE html>
<html>
<head>
<title>123解析</title>
<style>
body {
font-family: "Helvetica Neue", Arial, sans-serif;
background-color: #f5f5f7;
margin: 0;
padding: 0;
display: flex;
align-items: center;
justify-content: center;
min-height: 100vh;
}

.container {
max-width: 600px;
padding: 20px;
box-sizing: border-box;
text-align: center;
}

h1 {
font-size: 32px;
font-weight: bold;
color: #333333;
margin-bottom: 40px;
margin-top: 40px;
}

form {
margin-bottom: 40px;
}

label {
display: block;
font-size: 20px;
font-weight: bold;
color: #333333;
margin-bottom: 10px;
}

input[type="text"] {
width: 100%;
padding: 12px;
font-size: 16px;
border: 1px solid #cccccc;
box-sizing: border-box;
margin-bottom: 20px;
}

input[type="submit"] {
padding: 12px 24px;
font-size: 18px;
font-weight: bold;
color: #ffffff;
background-color: #0070c9;
border: none;
cursor: pointer;
}

.download-link {
margin-top: 20px;
display: flex;
align-items: center;
justify-content: center;
}

.error-icon {
margin-right: 10px;
color: #ff0000;
font-size: 24px;
}

.success-icon {
margin-right: 10px;
color: #009900;
font-size: 24px;
}

a {
display: inline-block;
padding: 12px 24px;
font-size: 18px;
font-weight: bold;
color: #ffffff;
background-color: #0070c9;
text-decoration: none;
}

a:hover {
background-color: #0057a0;
}
</style>
</head>
<body>
<div class="container">
<h1>123解析</h1>
<form method="post" action="">
<label for="shareUrl">分享链接:</label>
<input type="text" id="shareUrl" name="shareUrl" required>
<input type="submit" name="submit" value="解析">
</form>

<?php if(isset($_POST['submit']) && isset($redirectUrl)): ?>

<?php endif; ?>

<?php
if(isset($_POST['submit'])) {
$shareUrl = $_POST['shareUrl'];
$shareCode = "";
$pattern = "/(?<=\/s\/)[^\/.]+/";
preg_match($pattern, $shareUrl, $match);

if ($match) {
$shareId = $match[0];
$extractCodePattern = "/提取码:(\w+)/";
preg_match($extractCodePattern, $shareUrl, $extractCodeMatch);

if ($extractCodeMatch) {
$shareCode = $extractCodeMatch[1];
}

// Get user information
getInfo($shareId, $shareCode);
} else {
echo'<span class="error-icon">✗</span>'. "错误: 123pan URL 未找到!";
}
}

function getInfo($shareId, $shareCode) {
$requestUrl = "https://www.123pan.com/b/api/share/get?limit=100&next=1&orderBy=share_id&orderDirection=desc&shareKey=" . $shareId . "&SharePwd=" . $shareCode . "&ParentFileId=0&Page=1";
$opts = array(
'http' => array(
'header' => "User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36 Edg/109.0.1518.100\r\n"
)
);
$context = stream_context_create($opts);
$responseText = file_get_contents($requestUrl, false, $context);

parseInfo($responseText, $shareId);
}

function parseInfo($str, $shareId) {
$data = json_decode($str, true);

if ($data['code'] == 0) {
$type = $data['data']['InfoList'][0]['Type'];

if ($type == 0) {
$fileId = $data['data']['InfoList'][0]['FileId'];
$size = $data['data']['InfoList'][0]['Size'];
$s3KeyFlag = $data['data']['InfoList'][0]['S3KeyFlag'];
$etag = $data['data']['InfoList'][0]['Etag'];

// Perform second step
combinedData($shareId, $fileId, $size, $s3KeyFlag, $etag);
} else {
echo "错误: Folder parsing is currently not supported.";
}
} else {
$code = $data['code'];
$message = $data['message'];
echo '<span class="error-icon">✗</span>'."错误: 错误码" . $code . "//" . $message;
}
}

function combinedData($shareId, $fileId, $size, $s3KeyFlag, $etag) {
$requestUrl = "https://www.123pan.com/b/api/share/download/info";
$postData = json_encode(array(
"ShareKey" => $shareId,
"FileID" => $fileId,
"S3keyFlag" => $s3KeyFlag,
"Size" => $size,
"Etag" => $etag
));

$opts = array(
'http' => array(
'header' => "User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36 Edg/109.0.1518.100\r\n" .
"Content-Type: application/json;charset=UTF-8\r\n",
'method' => 'POST',
'content' => $postData
)
);
$context = stream_context_create($opts);
$response = file_get_contents($requestUrl, false, $context);

parseDownloadURL($response);
}

function parseDownloadURL($str) {
$data = json_decode($str, true);

if ($data['code'] == 0) {
$downloadURL = $data['data']['DownloadURL'];
$downloadURL = extractDownloadLink($downloadURL);
getDirectLink($downloadURL);
} else {
$code = $data['code'];
$message = $data['message'];
echo '<span class="error-icon">✗</span>'."错误: 错误码" . $code . "//" . $message;
}
}

function extractDownloadLink($str) {
$pattern = "/params=([^&]+)/";
preg_match($pattern, $str, $match);

if ($match) {
$paramsValue = $match[1];
$decodedString = base64_decode($paramsValue);

// Check if auto_redirect parameter exists
if (strpos($decodedString, 'auto_redirect') === false) {
if (strpos($decodedString, '?') !== false) {
$decodedString .= "&auto_redirect=0";
} else {
$decodedString .= "?auto_redirect=0";
}
}

return $decodedString;
} else {
echo "Failed to extract Download URL";
}
}

function getDirectLink($requestUrl) {
$opts = array(
'http' => array(
'header' => "User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36 Edg/109.0.1518.100\r\n"
)
);
$context = stream_context_create($opts);
$responseText = file_get_contents($requestUrl, false, $context);

parseDirectLink($responseText);
}

function parseDirectLink($str) {
$data = json_decode($str, true);

if ($data['code'] == 0) {
$redirectUrl = $data['data']['redirect_url'];
echo '<span class="success-icon">✓</span><a href="' . $redirectUrl . '">点击下载</a>';
} else {
$code = $data['code'];
$message = $data['message'];
echo '<span class="error-icon">✗</span>'."错误: 错误码" . $code . "//" . $message;
}
}
?>
</div>
</body>
</html>

推荐阅读:

-->

下载说明:

1、本站资源都是白菜价出售,同样的东西,我们不卖几百,也不卖几十,甚至才卖几块钱,一个永久会员能下载全站100%源码了,所以单独购买也好,会员也好均不提供相关技术服务。

2、如果源码下载地址失效请/联系站长QQ进行补发。

3、本站所有资源仅用于学习及研究使用,请必须在24小时内删除所下载资源,切勿用于商业用途,否则由此引发的法律纠纷及连带责任本站和发布者概不承担。资源除标明原创外均来自网络整理,版权归原作者或本站特约原创作者所有,如侵犯到您权益请联系本站删除!

4、本站站内提供的所有可下载资源(软件等等)本站保证未做任何负面改动(不包含修复bug和完善功能等正面优化或二次开发);但本网站不能保证资源的准确性、安全性和完整性,用户下载后自行斟酌,我们以交流学习为目的,并不是所有的源码都100%无错或无bug;同时本站用户必须明白,【源码源码ui网】对提供下载的软件等不拥有任何权利(本站原创和特约原创作者除外),其版权归该资源的合法拥有者所有。

5、请您认真阅读上述内容,购买即以为着您同意上述内容。

一保站 » 解析123网盘链接 – PHP代码分享