你好我试图创建一个简单的脚本,它将使用我的专用服务器使用WHM创建一个帐户 这是简单的代码
<?php
// your WHM username
$whm_user = 'root';
// your WHM password
$whm_pass = 'pass';
// your WHM hostname
$whm_host = '10.10.10.10';
// new account domain or subdomain name
$user_domain = 'example.com';
// new account username (8 characters or less)
$user_name = 'example';
// new account password
$user_pass = 'example1245';
// new account contact email
$user_email = 'user@example.net';
// new account plan (must be an existing WHM plan)
$user_plan = 'Gold';
// create the account
$site = "https://{$whm_user}:{$whm_pass}@{$whm_host}:2087/scripts/wwwacct";
$params = "?plan={$user_plan}";
$params .= "&domain={$user_domain}";
$params .= "&username={$user_name}";
$params .= "&password={$user_pass}";
$params .= "&contactemail={$user_email}";
$url = $site.$params;
file_get_contents($url);
?>
这会返回错误
[function.file-get-contents]: failed to open stream: No error in C:\AppServ\www\cp\create-whm-account.php on line 35
然后我尝试使用CURL
<?php
// your WHM username
$whm_user = 'root';
// your WHM password
$whm_pass = 'pass';
// your WHM hostname
$whm_host = '10.10.10.10';
// new account domain or subdomain name
$user_domain = 'example.com';
// new account username (8 characters or less)
$user_name = 'example';
// new account password
$user_pass = 'example1245';
// new account contact email
$user_email = 'user@example.net';
// new account plan (must be an existing WHM plan)
$user_plan = 'Gold';
// create the account
$site = "https://{$whm_user}:{$whm_pass}@{$whm_host}:2087/scripts/wwwacct";
$params = "?plan={$user_plan}";
$params .= "&domain={$user_domain}";
$params .= "&username={$user_name}";
$params .= "&password={$user_pass}";
$params .= "&contactemail={$user_email}";
$url = $site.$params;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($ch);
curl_close($ch);
?>
它不会返回任何错误,也不会起作用 我不需要返回任何输出,因为这将在另一个函数中工作,所以我不需要显示任何结果只是在后台创建帐户
答案 0 :(得分:0)
我注意到您要求提供HTTPS网址。可能需要额外的CURL标志。很有可能:
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);