Re: Re: curl

From: Date: Wed, 07 Mar 2007 14:45:38 +0000
Subject: Re: Re: curl
References: 1 2  Groups: php.db 
Request: Send a blank email to php-db+get-43222@lists.php.net to get a copy of this message
Hi, what version of php and curl are you using ? does your code work (without getting a segmentation fault) for this link : https://doc.telin.nl/dscgi/ds.py/Get/File-29224 ? this is the code I am trying to use: $ch = curl_init(); $timeout = 5; // set to zero for no timeout curl_setopt ($ch, CURLOPT_URL, $url2); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout); $file_contents = curl_exec($ch); curl_close($ch); $lines = array(); $lines = explode("\n", $file_contents); Ron btw: I had to resend the msg because: ----- The following addresses had permanent fatal errors ----- <anclark@ara.com>
    (reason: 550 Denied as you are on an RBL)
uuuhhm what is RBL ? and why am I on it ? Ron datsclark wrote:
I found this class in the PHP documentation, and edited it a bit. It works for me, getting the header and the body separately. You may want to experiment with the "<html" string position to cut the curl response up with. class CCurl { var $m_handle; var $m_header; var $m_body; var $m_info; function CCurl($sUrl) { $this->m_handle = curl_init(); curl_setopt($this->m_handle, CURLOPT_URL, $sUrl); return; } function setOpt($sOpt, $sVal) { curl_setopt($this->m_handle, $sOpt, $sVal); return; } function getHeader() { return $this->m_header; } function execute() { $sResponse = curl_exec($this->m_handle); $this->m_body = substr($sResponse, strpos($sResponse, "<html")); $this->m_header = substr($sResponse, 0, -strlen($this->m_body)); return $this->m_body; } function getInfo() { return $this->m_info = curl_getinfo($this->m_handle); } function close() { curl_close($this->m_handle); return; } } "Ron Croonenberg" <ronc@depauw.edu> wrote in message news:45EE30D3.1060905@depauw.edu...
Hello, I am working on an app with php and MySQL but I have a curl question if you don't mind. I need to check a url (from the db) but I want the get the header info first. now what i want is exactly what "curl -I "http://........" outputs. I am trying to write a php script that produces the same output, but it seems to break (that pesky segment fault again) any ideas ? thanks, Ron -- ================================================================= It's is not, it isn't ain't, and it's it's, not its, if you mean it is. If you don't, it's its. Then too, it's hers. It isn't her's. It isn't our's either. It's ours, and likewise yours and theirs.
                                             -- Oxford Uni Press
=================================================================
Ron Croonenberg                   |
                                  | Phone: 1 765 658 4761
Lab Instructor &                  | Fax:   1 765 658 4732
        Technology Coordinator    |
                                  |
Department of Computer Science    | e-mail: ronc@DePauw.edu
DePauw University                 |
275 Julian Science & Math Center |
602 South College Ave.            |
Greencastle, IN  46135            |
================================================================= http://www.csc.depauw.edu/RonCroonenberg.html =================================================================
-- ================================================================= It's is not, it isn't ain't, and it's it's, not its, if you mean it is. If you don't, it's its. Then too, it's hers. It isn't her's. It isn't our's either. It's ours, and likewise yours and theirs. -- Oxford Uni Press ================================================================= Ron Croonenberg | | Phone: 1 765 658 4761 Lab Instructor & | Fax: 1 765 658 4732 Technology Coordinator | | Department of Computer Science | e-mail: ronc@DePauw.edu DePauw University | 275 Julian Science & Math Center | 602 South College Ave. | Greencastle, IN 46135 | ================================================================= http://www.csc.depauw.edu/RonCroonenberg.html =================================================================

« previous php.db (#43222) next »