Community Forums
Connect with us on LinkedIn
+ Reply to Thread
Results 1 to 5 of 5
  1. #1
    Member
    Join Date
    Nov 2008
    Posts
    5

    Exclamation API : call to change owner?

    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
    Last edited by BartVenken; 11-25-2008 at 12:06 PM.

  2. #2
    cPanel Staff cPanelMatt's Avatar
    Join Date
    Apr 2005
    Location
    Houston, TX
    Posts
    409

    Default

    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;
    Matt Dees
    Integration Developer
    cPanel, Inc.
    cPanel Integration Blog

  3. #3
    Member
    Join Date
    Nov 2008
    Posts
    5

    Default

    Thanks a lot! I'll give it a try.

    I guess I need to replace 127.0.0.1 with the actual domain?

  4. #4
    cPanel Staff cPanelMatt's Avatar
    Join Date
    Apr 2005
    Location
    Houston, TX
    Posts
    409

    Default

    Bart, Yes, you will need to put in the actual domain, unless you are running it on the same server as WHM.
    Matt Dees
    Integration Developer
    cPanel, Inc.
    cPanel Integration Blog

  5. #5
    Member
    Join Date
    Nov 2008
    Posts
    5

    Default

    Hi again,

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

    Bart Venken

Similar Threads & Tags
Similar threads

  1. API call from within CustomEventHandler
    By tizoo in forum cPanel Developers
    Replies: 2
    Last Post: 06-02-2011, 10:59 AM
  2. API Change Owner not working
    By derfuhrer2007 in forum cPanel Developers
    Replies: 4
    Last Post: 02-12-2010, 01:52 PM
  3. API : call to change owner?
    By BartVenken in forum New User Questions
    Replies: 1
    Last Post: 11-25-2008, 01:53 PM
  4. API call to change cpanel password?
    By electric in forum cPanel and WHM Discussions
    Replies: 16
    Last Post: 07-27-2007, 08:58 AM
Linkedin       Facebook       Twitter       RSS       Flickr       YouTube