【发布时间】:2023-03-26 22:28:01
【问题描述】:
我正在编写一个工具来获取 Whois 信息,我需要为此使用 WHMCS API。
这是他们提供的代码:
$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' => 'DomainGetWhoisInfo',
// See https://developers.whmcs.com/api/authentication
'username' => 'IDENTIFIER_OR_ADMIN_USERNAME',
'password' => 'SECRET_OR_HASHED_PASSWORD',
'domainid' => '1',
'responsetype' => 'json',
)
)
);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);
curl_close($ch);
我想在没有 PHP 的情况下在 Python 中使用这个请求。我应该使用什么库以及如何在有效负载中设置变量?(php 或 python 样式?)
【问题讨论】: