此命令可用於針對 WHMCS 中的注冊用戶驗證電子郵件地址和密碼。
如果電子郵件地址有效且密碼正確,則會話將作為創建密碼哈希的一部分啟動。此會話可用於遠程登錄(見下文),但如果使用 LocalAPI,可能會影響腳本的其他方麵。經過驗證的登錄將更新為客戶帳戶存儲的上次登錄時間。成功後,將返回 userid 和 passwordhash。這可用於通過將會話 key ‘login_auth_tk’ 設置為 passwordhash 來建立經過身份驗證的會話。
注意:如果啟用了會話 IP 驗證,則必須通過本地 API 執行此 API 調用才能接收有效的哈希。
注意:此 API 提供的登錄函數被用於遠程登錄函數的 CreateSsoToken (https://developers.whmcs.com/api-reference/createssotoken/) 和用於身份驗證服務/憑證驗證的 OpenID Connect (https://docs.whmcs.com/OpenID_Connect) 取代。鑒於這些更強大和現代的實現,此 API 可能在未來被棄用。
請求參數
| 參數 | 類型 | 說明 | 必需的 |
|---|---|---|---|
| action | string | “ValidateLogin” | Required |
| string | 用戶電子郵件地址 | Required | |
| password2 | string | 驗證密碼 | Required |
響應參數
| 參數 | 類型 | 說明 |
|---|---|---|
| result | string | 操作結果:成功或錯誤 |
| userid | int | 用戶身份 |
| passwordhash | string | 登錄會話令牌 - 如果帳戶不需要 Two-Factor 身份驗證,則返回 |
| twoFactorEnabled | bool | 如果為給定帳戶啟用了 Two-Factor 身份驗證,則為真 |
示例請求 (CURL)
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://www.example.com/includes/api.php');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,
http_build_query(
array(
'action' => 'ValidateLogin',
// See https://developers.whmcs.com/api/authentication
'username' => 'IDENTIFIER_OR_ADMIN_USERNAME',
'password' => 'SECRET_OR_HASHED_PASSWORD',
'email' => '[email protected]',
'password2' => 'abc123',
'responsetype' => 'json',
)
)
);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);
curl_close($ch);
示例請求(本地 API)
$command = 'ValidateLogin';
$postData = array(
'email' => '[email protected]',
'password2' => 'abc123',
);
$adminUsername = 'ADMIN_USERNAME'; // Optional for WHMCS 7.2 and later
$results = localAPI($command, $postData, $adminUsername);
print_r($results);
示例響應 JSON
{
"result": "success",
"userid": "1",
"passwordhash": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"twoFactorEnabled": "false"
}
錯誤響應
可能的錯誤條件響應包括:
- 電子郵件或密碼無效
相關用法
- PHP WHMCS ViewOrderDetailsPage用法及代碼示例
- PHP WHMCS ViewInvoiceDetailsPage用法及代碼示例
- PHP WHMCS ClientAreaPageDownloads用法及代碼示例
- PHP Ds\Map isEmpty()用法及代碼示例
- PHP PHPUnit assertIsNotFloat()用法及代碼示例
- PHP disk_total_space()用法及代碼示例
- PHP ReflectionClass getTraitAliases()用法及代碼示例
- PHP hash_hmac()用法及代碼示例
- PHP String wordwrap()用法及代碼示例
- PHP XMLWriter endPi()用法及代碼示例
- PHP SimpleXMLElement children()用法及代碼示例
- PHP IntlCalendar getTimeZone()用法及代碼示例
- PHP SplPriorityQueue isCorrupted()用法及代碼示例
- PHP XMLReader::getParserProperty()用法及代碼示例
- PHP imagegif()用法及代碼示例
- PHP imageresolution()用法及代碼示例
- PHP array_reverse()用法及代碼示例
- PHP IntlCalendar getActualMinimum()用法及代碼示例
- PHP WHMCS DomainGetWhoisInfo用法及代碼示例
- PHP metaphone()用法及代碼示例
- PHP WHMCS ClientAreaHeaderOutput用法及代碼示例
- PHP imagebmp()用法及代碼示例
- PHP DOMDocument createElementNS()用法及代碼示例
- PHP prev()用法及代碼示例
- PHP Ds\Deque filter()用法及代碼示例
注:本文由純淨天空篩選整理自whmcs.com大神的英文原創作品 ValidateLogin。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。
