开发者

execute external page while doing some function with php?

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 = '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);
?>

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 = '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); 
?>

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


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜