Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

API : call to change owner?

Discussion in 'cPanel Developers' started by BartVenken, Nov 25, 2008.

  1. BartVenken

    BartVenken Member

    Joined:
    Nov 25, 2008
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    51
    Hi,

    Is there a way to change the owner of a hosting account (via the api) as it is possible in WHM?

    When I paste something like this into the browser's addressbar, it works :

    mywhmdomain/scripts/dochangeowner?user=username&owner=ownername

    I would like to 'run' this url without actually opening the page. fopen and curl won't do the trick though.

    Anyone any ideas?


    Thnx in advance
    Bart Venken
     
    #1 BartVenken, Nov 25, 2008
    Last edited: Nov 25, 2008
  2. MattDees

    MattDees Well-Known Member

    Joined:
    Apr 29, 2005
    Messages:
    416
    Likes Received:
    1
    Trophy Points:
    243
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    Bart, I find the that following script does the trick just fine:

    Code:
    $whmusername = "root";
    $whmpassword = "somepassword";
    $username = "someuser";
    $owner = "root";
    
    $query = "https://127.0.0.1:2087/scripts/dochangeowner?user=" . $username . "&owner=" . $owner;       #build query
    
    $curl = curl_init();								# Create Curl Object
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER,0);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER,1);		# Return contents of transfer on curl_exec
    curl_setopt($curl, CURLOPT_SSL_VERIFYHOST,0);		# Allow self-signed certs
    curl_setopt($curl, CURLOPT_USERPWD, $whmusername.":".$whmpassword);  # set the username and password
    curl_setopt($curl, CURLOPT_URL, $query);
    $result = curl_exec($curl);
    if ($result == false) {
    	error_log("curl_exec threw an error for $query");
    }
    print $result;
    
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. BartVenken

    BartVenken Member

    Joined:
    Nov 25, 2008
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    51
    Thanks a lot! I'll give it a try.

    I guess I need to replace 127.0.0.1 with the actual domain?
     
  4. MattDees

    MattDees Well-Known Member

    Joined:
    Apr 29, 2005
    Messages:
    416
    Likes Received:
    1
    Trophy Points:
    243
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    Bart, Yes, you will need to put in the actual domain, unless you are running it on the same server as WHM.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  5. BartVenken

    BartVenken Member

    Joined:
    Nov 25, 2008
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    51
    Hi again,

    I just tried your code and it works like a charm.
    Thnx a lot. Very much appreciated.

    Bart Venken
     
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice