SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Wizard Zaggs's Avatar
    Join Date
    Feb 2005
    Posts
    1,051
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Problem when using CURL

    Hi Guys...

    When I use the following script, it works fine (executes what it should do). However, upon executing curl_exec() I get a popup and asks me if I want to save the file, see this screenshot: http://www.exallgroup.com/screen.png

    This should not happen, it should just return the XML response packet. Any idea why it's doing this?

    My guess is it's a header problem, but i've tried everything. Can anyone shed some light on the problem?

    PHP Code:
    <?php
    $data 
    '
                        <?xml version="1.0" encoding="UTF-8" ?>
                          <packet version="'
    .$this->sitevar['parking_version'].'">
                            <site-alias>
                              <create>
                                <site-id>'
    .$this->sitevar['parking_primary_id'].'</site-id>
                                <name>'
    .$domain.'</name>
                              </create>
                            </site-alias>
                          </packet>'
    ;
                        
    $url "https://".$this->sitevar['parking_ip'].":".$this->sitevar['parking_port']."/".$this->sitevar['parking_path'];
                        
                        
    $headers = array(
                            
    "POST /enterprise/control/agent.php HTTP/1.1",
                            
    "Host: 94.23.155.228:8443",
                            
    "HTTP_AUTH_LOGIN: ".$this->sitevar['parking_username'],
                            
    "HTTP_AUTH_PASSWD: ".$this->sitevar['parking_password'],
                            
    "HTTP_PRETTY_PRINT: TRUE",
                            
    "Content-Length: ".strlen($data),
                            
    "Content-Type: text/xml");
                        
                        
    // Initalize the curl engine
                        
    $CurlHandle curl_init();
                        
    // Set the curl options
                        
    curl_setopt($CurlHandleCURLOPT_SSL_VERIFYHOST1);
                        
    // this line makes it work under https
                        
    curl_setopt($CurlHandleCURLOPT_SSL_VERIFYPEERFALSE);
                        
    // pass in the header elements
                        
    curl_setopt($CurlHandleCURLOPT_HTTPHEADER$headers);
                        
    // Set the URL to be processed
                        
    curl_setopt($CurlHandleCURLOPT_URL$url);
                        
    // Set the data to be send
                        
    curl_setopt($CurlHandleCURLOPT_POSTFIELDS$data);
                        
    // Return details
                        
    curl_setopt($CurlHandleCURLOPT_RETURNTRANSFER1);
                        
                        
    $Return curl_exec($CurlHandle);
                        
                        
                        
                        
    print_r($Return); exit;
    ?>

  2. #2
    SitePoint Evangelist speda1's Avatar
    Join Date
    Jan 2002
    Posts
    550
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It seems that a file, admincp.php is returned on curl, not an array or data object.

  3. #3
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,748
    Mentioned
    72 Post(s)
    Tagged
    0 Thread(s)
    why are you print_r'ing your return? Surely you just want to output the data returned (What data is it returning?)


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •