The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

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:
    1
    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 cPanel Product Owner
    Staff Member

    Joined:
    Apr 29, 2005
    Messages:
    417
    Likes Received:
    1
    Trophy Points:
    18
    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;
    
     
  3. BartVenken

    BartVenken Member

    Joined:
    Nov 25, 2008
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    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 cPanel Product Owner
    Staff Member

    Joined:
    Apr 29, 2005
    Messages:
    417
    Likes Received:
    1
    Trophy Points:
    18
    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.
     
  5. BartVenken

    BartVenken Member

    Joined:
    Nov 25, 2008
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    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