在使用 php 执行某些功能时执行外部页面?

发布于 2024-11-27 18:40:24 字数 2415 浏览 0 评论 0原文

你好,我正在尝试创建一个简单的脚本,它将使用 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 = '[email protected]';

// 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 = '[email protected]';

// 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); 
?>

它不会返回任何错误,也不起作用 我不需要返回任何输出,因为这将在另一个函数中工作,所以我不需要显示任何结果,只需在后台创建帐户

hello im trying to create a simple script which will create an account with my dedicated server using WHM
here is the simple code

<?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 = '[email protected]';

// 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);
?>

this return an error

[function.file-get-contents]: failed to open stream: No error in C:\AppServ\www\cp\create-whm-account.php on line 35

then i tried to use 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 = '[email protected]';

// 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); 
?>

it doesn't return any error and doesn't work neither
i don't need to return any output as this will work within another functions so i don't need to show any result just create the account within the background

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我偏爱纯白色 2024-12-04 18:40:24

我注意到您正在请求 HTTPS URL。可能需要额外的 CURL 标志。很可能:

curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,  2); 

另请参阅: PHP: Curl从 HTTPS 获取 html 页面

I noticed that you are requesting a HTTPS URL. Extra CURL flags might be required. Very likely:

curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,  2); 

See also: PHP: Curl to fetch html page from HTTPS

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文