Re: Re: curl

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxx>
    (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@xxxxxxxxxx> wrote in message news:45EE30D3.1060905@xxxxxxxxxxxxx
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@xxxxxxxxxx
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@xxxxxxxxxx
 DePauw University                 |
 275 Julian Science & Math Center  |
 602 South College Ave.            |
 Greencastle, IN  46135            |
=================================================================
 http://www.csc.depauw.edu/RonCroonenberg.html
=================================================================

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux