none
Unable to download .zip

    Question

  • 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 microsoft.com? 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,


    Mike

    Monday, December 16, 2013 11:25 PM

Answers

  • 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!

    Mike

    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 microsoft.com 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:

    https://api.bingads.microsoft.com/ReportDownload/Download.aspx

    and not:

    https://download.api.bingads.microsoft.com/ReportDownload/Download.aspx

    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?
    http://msdn.microsoft.com/en-US/library/bing-ads-reporting-request-and-download-a-keyword-performance-report-in-php.aspx

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

    Regards,
    Eric

    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 https://download.api.bingads.microsoft.com/ReportDownload/Download.aspx and wrote it to <a href="log_microsoft.txt">this text file</a>

    <?php
    $fileName = "log_microsoft.txt";
    $downloadURL = "https://download.api.bingads.microsoft.com/ReportDownload/Download.aspx";
    $handleOut = fopen("$fileName", "w");
    $handleIn = fopen($downloadURL,"r");

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

    fclose($handleIn);
    fclose($handleOut);
    ?>

    In curl, this is my code:

    <?php

    $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);
    curl_exec($ch);
    $retcode = curl_getinfo($ch);
    curl_close($ch);
    fclose($fp);

    ?>

    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] => https://download.api.bingads.microsoft.com/ReportDownload/Download.aspx?q=%2b4TmDHbPqpW2DF3NGI4XlOB0oxpU%2fOA4Ehb%2bj0wcvHiMa9qvT9yiOilAINK1EU%2bl0d7VF3EIErezV8t0bBM2DT8GpE3HYcpZpK46V79x%2bT6SLjyWR6D%2bfeoW6DA3zk7DQMRDTKcBFb7ETodsVAscQc0zasCaOW8WsLOp9fKjE6wlk3X8eYqi%2f7d6TMFaUOpxLqA79I0CM8nyw2dPpDr5w7j1BF0VDI1blsaz18rM6tU%2fvwZEQiQfahVB5hYyaaoF8n566HqmWWRvasJYUoSppxhLs6pzvPCz7CSzU76MoGpO%2fRFkmrFAvUDKISL8N5eEig%3d%3d [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.

    • Proposed as answer by Eric UrbanModerator Wednesday, December 18, 2013 6:10 PM
    • Unproposed as answer by iwpgroup Wednesday, December 18, 2013 6:35 PM
    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".

    Thanks,

    Mike



    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!

    Mike

    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

    Regards

    Gopal Rathod

    Monday, January 13, 2014 10:37 AM