Unable to download .zip


  • I just transferred my program to a new server with a very similar setup (Apache 2.4, running from PHP). A keyword performance report, and account performance report is generated with the API, however it is not able to download. I am not getting any SOAP faults or server errors. I simply get an empty zip file. Is it possible that my server's IP address is blocked from I tested downloading the file from another URL and it works fine. The file from the downloadUrl also opens in a browser. I tested this with the old server with no problems. I turned off the firewall, and do not use Mod_Security.

    Thank you,


    Monday, December 16, 2013 11:25 PM


  • Hi Eric, a PHP Pear package was updated, which gave the server the fix. Apparently OpenSSL was not configured correctly with PHP on 64-bit systems. I appreciate your help!


    Thursday, December 19, 2013 3:07 PM

All replies

  • In addition, the header code with CURL is returning 0 instead of 200 or 404. Tried this from my old server and 200 comes back as it should. Certainly seems like my IP is being blocked from accessing the file.
    Tuesday, December 17, 2013 2:49 PM
  • As suggested in other posts, I enabled curl opt to use SSL 3. I was able to retrieve the header. However fopen still did not download the zip file. I am able to fetch secure pages from with fopen (and ran many other tests to make sure the issue is not on my server), but not from the download URL. Are there IP's that are registered within the API for security purposes?
    Tuesday, December 17, 2013 11:05 PM
  • Okay, another update. I can get only a response code of 200 by using curl, I was able to transfer files from:

    and not:

    So I am nearly certain that the subdomain "download" is blocking my URL from accessing the file, by firewall or other means.

    Please help, I am totally stuck. I exchanged about 20 messages with my hosting provider and 2 full days looking at settings, running tests, etc. trying to figure out why the file won't transfer.

    Wednesday, December 18, 2013 3:08 AM
  • Hello.

    Have you tried the code sample posted here?

    Otherwise do you have any code you would share related to the cURL settings and download? 


    Wednesday, December 18, 2013 4:48 AM
  • Hi Eric, yes, I tried that, using the DownloadFile{} function. A simple fopen of the download URL returns nothing, curl seems to at least let me view the headers, but still no file. I tested this on my old server/IP's and the 404 page returns as it should. Here is the code, testing the URL that seems to be blocking me.

    Downloaded content from and wrote it to <a href="log_microsoft.txt">this text file</a>

    $fileName = "log_microsoft.txt";
    $downloadURL = "";
    $handleOut = fopen("$fileName", "w");
    $handleIn = fopen($downloadURL,"r");

    while (!feof($handleIn)){
    $content = fread($handleIn, 8192);
    print_r ($content);


    In curl, this is my code:


    $ch = curl_init($downloadURL);
    $fp = fopen($localFileName, 'w');

    curl_setopt($ch, CURLOPT_SSLVERSION, 3);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($ch, CURLOPT_FILE, $fp);
    $retcode = curl_getinfo($ch);


    And these are the return values, however I am unable to retrieve the file, it timesout after 20-30 seconds and returns no response:

    Array ( 
    [url] => [content_type] => application/x-zip-compressed 
    [http_code] => 200 
    [header_size] => 305 
    [request_size] => 450 
    [filetime] => -1 
    [ssl_verify_result] => 0 
    [redirect_count] => 0 
    [total_time] => 0.144842 
    [namelookup_time] => 0.002172 
    [connect_time] => 0.027903 
    [pretransfer_time] => 0.100502 
    [size_upload] => 0 
    [size_download] => 584 
    [speed_download] => 4031 
    [speed_upload] => 0 
    [download_content_length] => 584 
    [upload_content_length] => 0 
    [starttransfer_time] => 0.144807 
    [redirect_time] => 0 
    [certinfo] => Array ( ) 
    [primary_ip] => x
    [primary_port] => 443 
    [local_ip] => x
    [local_port] => 41195 
    [redirect_url] =>

    Wednesday, December 18, 2013 4:00 PM
  • Hello.

    Thanks for the details. I was able to repro getting an empty ZIP file using your code. Adding the following cURL option flag resolves that issue.

    curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0);

    I hope this helps.

    Wednesday, December 18, 2013 6:10 PM
  • Hi Eric, this didn't fix the issue. Is it possible to verify that the API isn't blocking my machine (x.x.x.x)? Softlayer suspects so as well. I am not getting a return fopen on any subdomain "download".



    Wednesday, December 18, 2013 6:21 PM
  • Hi Eric, a PHP Pear package was updated, which gave the server the fix. Apparently OpenSSL was not configured correctly with PHP on 64-bit systems. I appreciate your help!


    Thursday, December 19, 2013 3:07 PM
  • Hi Mike.

    Great to hear, and thanks for confirming!

    Friday, December 20, 2013 3:43 PM
  • Hello,

    yes, its only issue of latest version of OpenSSL 1.0.1e-fips 11 Feb 2013. . you can use cURL instead of fopen  so its working fine


    Gopal Rathod

    Monday, January 13, 2014 10:37 AM