Here is the code:
Code: Select all
<?php
$fp = fopen("dnld.txt","w");
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://hostname/discoverer4i/viewe
r?us=username&pw=password&db=database&wb=test_download4&fm=txt");
curl_setopt($ch, CURLOPT_FILE, $fp);
##curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
##curl_setopt($ch, CURLOPT_UNRESTRICTED_AUTH, true);
curl_exec($ch);
curl_close($ch);
fclose($fp);
?>Here is the output of dnld.txt. It contains the redirected path.
This is not the output I want at all. It is supposed to be a report listing with various columns. Nothing at all like what the output I received. I have also tried to make the format Excel as well. Any ideas? I'm stumped.<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<HTML><HEAD>
<TITLE>302 Found</TITLE>
</HEAD><BODY>
<H1>Found</H1>
The document has moved <A HREF="/discoverer4i/viewer?ws=Sheet~201&db=database&
amp;wb=test_download4&fm=txt&us=USERNAME">here</A>.<P>
<HR>
<ADDRESS>Oracle HTTP Server Powered by Apache/1.3.19 Server at <A HREF="mailto:h
martin@blahblah">hostname</A> Port ####</ADDRESS>
</BODY></HTML>
CURLOPT_FOLLOWLOCATION: TRUE to follow any "Location: " header that the server sends as part of the HTTP header (note this is recursive, PHP will follow as many "Location: " headers that it is sent, unless CURLOPT_MAXREDIRS is set).
CURLOPT_UNRESTRICTED_AUTH: TRUE to keep sending the username and password when following locations (using CURLOPT_FOLLOWLOCATION), even when the hostname has changed.
PLease let me know if any further info is needed.
Thanks!