note 69175 added to ref.curl
| From: | jon at jonroig--- dot com | Date: | Fri, 25 Aug 2006 13:53:20 +0000 |
| Subject: | note 69175 added to ref.curl | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-116320@lists.php.net to get a copy of this message | ||
For anyone who is having trouble getting some of the advanced functionality to work in whatever
version of PHP you have, I wrote a little wrapper for the command line version of curl. The function
below is for Windows (hence, the curl.exe), but it works the same way under Linux or whatever.
The curl man page enumerates a ton of options you can use...
function curlPageGrabber($destinationURL, $refererURL, $postData, $autoForward = false,
$autoGrabCookies = true, $curlDebug = false)
{
$curlString = "c:\curl\curl.exe -i -v -m 30 -L -b c:\curl\cookiejar.txt -c
c:\curl\cookiejar.txt ";
$curlString .= " -A \"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR
1.1.4322;)\" ";
$curlString .= " -H \"Accept-Language: en-us\" ";
$curlString .= " -H \"Accept-Encoding: gzip, deflate\" ";
$curlString .= " -H \"Host: affiliate-program.amazon.com\" ";
$curlString .= " -H \"Accept: */*\" ";
$curlString .= " --compressed ";
//$curlString .= " --trace-ascii ";
if ($refererURL != '')
{
$curlString .= "-e \"".$refererURL."\" ";
}
if ($postData != '')
{
$curlString.= " -d \"$postData\" ";
}
$curlString .= $destinationURL;
if ($curlDebug == true)
{
echo "<p>curlString: $curlString</p>";
}
$temp = exec($curlString, $retval);
$htmlData = '';
foreach ($retval as $arrayLine)
{
$htmlData .= $arrayLine."\r\n";
}
if ($curlDebug == true)
{
echo "<textarea cols=80 rows=20>$htmlData</textarea>";
}
return $htmlData;
} // end function
----
Server IP: 64.71.164.2
Probable Submitter: 216.185.175.114
----
X-Spam-Status: No, hits=3.3 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER,
HTML_MESSAGE autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/ref.curl.php
Edit -- https://master.php.net/note/edit/69175
Del: integrated -- https://master.php.net/note/delete/69175/integrated
Del: useless -- https://master.php.net/note/delete/69175/useless
Del: bad code -- https://master.php.net/note/delete/69175/bad+code
Del: spam -- https://master.php.net/note/delete/69175/spam
Del: non-english -- https://master.php.net/note/delete/69175/non-english
Del: in docs -- https://master.php.net/note/delete/69175/in+docs
Del: other reasons-- https://master.php.net/note/delete/69175
Reject -- https://master.php.net/note/reject/69175
Search -- https://master.php.net/manage/user-notes.php