Forum Moderators: coopster
$cURL = curl_init();
curl_setopt($ch, CURLOPT_COOKIEFILE, "cookies.txt");
curl_setopt($ch, CURLOPT_COOKIEJAR, "cookies.txt");
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt ($ch, CURLOPT_COOKIE, session_name().'='.session_id() );
curl_setopt($cURL, CURLOPT_URL, "http://www.example.net");
curl_setopt($cURL, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($cURL, CURLOPT_HEADER, 1);
curl_setopt($cURL, CURLOPT_FAILONERROR, 1);
curl_setopt($cURL, CURLOPT_REFERER, "http://www.callsip.net");
curl_setopt($cURL, CURLOPT_RETURNTRANSFER, 1);
$strContent = curl_exec($cURL);
echo $strContent;
curl_close($cURL);
It seems to work fine, cept the cookie information is displayed before the <head> tag like this:
HTTP/1.1 200 OK
Date: Sun, 18 Jun 2006 05:44:31 GMT
Server: Apache
Set-Cookie: 88f958c6df8eb08d5cce7eecd5e44938=-; path=/
Set-Cookie: virtuemart=ecd7e975e042906e25a6b6bf17938a72; path=/
Expires: Mon, 26 Jul 1997 05:00:00 GMT
Cache-Control: no-store, no-cache, must-revalidate
Pragma: no-cache
Last-Modified: Sun, 18 Jun 2006 05:44:31 GMT
Cache-Control: post-check=0, pre-check=0
Transfer-Encoding: chunked
Content-Type: text/html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
I wouldn't mind if I didn't see it when I look at the page... is there a way to hide this or make my curl work right?
$response_start = strPos($strContent, "<!DOCTYPE html PUBLIC");
$response_end = strPos($strContent, "</html>");
$temp_code = substr($strContent, $response_start, ($response_end - $response_start));
echo "$temp_code";
This grabed the first line and then everything after it... seemed to work as well..
Hopefully this thread helps others!