note 72608 added to ref.curl
| From: | gordon_e_rouse at yahoo dot com dot au | Date: | Thu, 25 Jan 2007 22:24:00 +0000 |
| Subject: | note 72608 added to ref.curl | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-122206@lists.php.net to get a copy of this message | ||
Using curl to take snapshots of the current page for emailing the HTML is a clever little idea. (ie:
Email this page to a friend)
//to be explained below!
session_write_close();
$pageurl = "http://www.site.com/content.php?PHPSESSID=123XYZ
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_URL, $pageurl );
$html = curl_exec ( $ch );
curl_close($ch);
//then you need to fix pathing to absolute
$search = "/(src|href|background)=\"[^:,^>,^\"]*\"/i";
preg_match_all ( $search, $html, $a_matches );
//you can figure out the rest ! but thought the reg expression is useful as well
But here is the catch, you may want to make sure curl connects to the server under the same session
as the browser. So naturally you pass the session cookie through the curl system either by the
cookie jar system, or through the query string in the path.
This is where you will get stuck. PHP will need write access to the same session file
simultaneously!! causing serious hanging issues!
This is why you should close off your session before you make curl take a page snapshot!
----
Server IP: 203.89.181.184
Probable Submitter: 222.154.242.155
----
Manual Page -- http://www.php.net/manual/en/ref.curl.php
Edit -- https://master.php.net/note/edit/72608
Del: integrated -- https://master.php.net/note/delete/72608/integrated
Del: useless -- https://master.php.net/note/delete/72608/useless
Del: bad code -- https://master.php.net/note/delete/72608/bad+code
Del: spam -- https://master.php.net/note/delete/72608/spam
Del: non-english -- https://master.php.net/note/delete/72608/non-english
Del: in docs -- https://master.php.net/note/delete/72608/in+docs
Del: other reasons-- https://master.php.net/note/delete/72608
Reject -- https://master.php.net/note/reject/72608
Search -- https://master.php.net/manage/user-notes.php