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!

[WHM] HTTP POST to scripts2/savezone

Discussion in 'cPanel Developers' started by NightRider, Oct 4, 2007.

  1. NightRider

    NightRider Active Member

    Joined:
    Jan 23, 2007
    Messages:
    27
    Likes Received:
    0
    Trophy Points:
    151
    Hello.

    I have finally developed a php scipt for editing dns zone, for specified domain, without having direct access to whm.
    The problem is how to send variables to scripts2/savezone via http post.
    I used curl method:

    PHP:
    $ch curl_init(); 

    $url "http://user:password@domain.com/whm/scripts2/savezone"
    $params "&line-100-2=IN&line-200-1=NS&......"

    curl_setopt($chCURLOPT_URL,$url); 
    curl_setopt($chCURLOPT_POST1); 
    curl_setopt($chCURLOPT_POSTFIELDS,$params); 

    $resultcurl_exec ($ch); 
    curl_close ($ch);  
    And there are two results:

    1. All fields for domain become empty or
    2. WHM reports a fatal error [a fatal error or timeout occurred while processing this directive]

    How do You suggest to send the updated data to script?

    Thanks.
     
    #1 NightRider, Oct 4, 2007
    Last edited: Oct 4, 2007
  2. NightRider

    NightRider Active Member

    Joined:
    Jan 23, 2007
    Messages:
    27
    Likes Received:
    0
    Trophy Points:
    151
    WHM developers, do you read? Answer something, please!
    What HTTP conditions does scripts2/savezone need for successfull execution of the request?

    I have also tried using access hash ( $curlheaders[0] = "Authorization: WHM user:hash"; ), but nothing :confused::confused::confused:
     
  3. cPanelDavidG

    cPanelDavidG Technical Product Specialist

    Joined:
    Nov 29, 2006
    Messages:
    11,216
    Likes Received:
    10
    Trophy Points:
    313
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    Note, as /scripts2 is designed for internal use rather than being used as an API - you may not receive much of a response to this thread. Note that all functions in /scripts2 are subject to change without notice as they are only intended for internal use.
     
  4. NightRider

    NightRider Active Member

    Joined:
    Jan 23, 2007
    Messages:
    27
    Likes Received:
    0
    Trophy Points:
    151
    I dont want to change the internal files. Simply I want to know how can I make the right request to /scripts2. I am able to use the remote client managing (creating, terminating, suspending etc.), but why I cant use the remote DNS managing???
     
  5. cPanelBilly

    cPanelBilly Guest

    1) This is not a means of support so it is not up to the developers to respond through here.
    2) This is not a supported way of doing this. Most likely you are not passing the correct or all of the parameters.
     
  6. NightRider

    NightRider Active Member

    Joined:
    Jan 23, 2007
    Messages:
    27
    Likes Received:
    0
    Trophy Points:
    151
    I am very very sad....
     
  7. wsenter

    wsenter Well-Known Member

    Joined:
    Aug 5, 2003
    Messages:
    88
    Likes Received:
    0
    Trophy Points:
    156
    Location:
    Texas
    I'm not sure why I'm even helping you as no one HAS to help. This is a 100% free forum and people can post where they like. Also it is hard to troubleshoot your code as you only gave us a small part. Here is some code for you. Hopefully it helps someone else out as well...

    Code:
    <?
    
        ######### Set up basic variables here #########
    	$username = "root";
    	$password = "123456";
    	$ip = "208.74.121.52";
    	$agent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)";
    
    	//build URL here
    	$url = "http://".$username.":".$password."@".$ip.":2086/scripts2/savezone";
    
        ######### Set up all the field values here#########
    	$fields = "line-100-2=IN&";
    	$fields .= "line-200-1=NS&";
    	$fields .= "another=more&";
    	$fields .= "last_one=here";
    
    
        ######### Prepare curl settings and variables #########
    	$ch=curl_init(); 
    	curl_setopt($ch, CURLOPT_URL, $url);
    	curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1); 
    	curl_setopt($ch, CURLOPT_POST, 1); 
    	curl_setopt($ch, CURLOPT_POSTFIELDS, $fields); 
    	curl_setopt($ch, CURLOPT_TIMEOUT, 120); 
    	curl_setopt($ch, CURLOPT_USERAGENT, $agent); 
    	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0); 
    	$buffer = curl_exec($ch);
    	curl_close($ch);
    
    ?>
    
    Try that and then let us know how it works. If it doesn't work...research a little more and also post ALL of your code.
     
  8. NightRider

    NightRider Active Member

    Joined:
    Jan 23, 2007
    Messages:
    27
    Likes Received:
    0
    Trophy Points:
    151
    It works!
    wsenter, if You need free quality hosting, please let me know ;)
     
  9. wsenter

    wsenter Well-Known Member

    Joined:
    Aug 5, 2003
    Messages:
    88
    Likes Received:
    0
    Trophy Points:
    156
    Location:
    Texas
    Of course it works. I'm a genius ;). No in all seriousness I actually love developing custom applications to interact with cPanel. Now if I could only do professionally for a job :(

    Let me know if you need anything else. Strange as it sounds I think this stuff is fun.
     
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