curl

curl

am 07.03.2007 04:26:11 von Ron Croonenberg

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
============================================================ =====

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

Re: curl

am 07.03.2007 15:08:15 von datsclark

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 " 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, " $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" 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
> ============================================================ =====

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

Re: Re: curl

am 07.03.2007 15:45:38 von Ron Croonenberg

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 -----

(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 " > 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, " > $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" 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
============================================================ =====

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

Re: Re: curl

am 07.03.2007 17:25:03 von datsclark

The code works with that link, although I wasn't able to immediately
download the file. I'm not sure whats up, but it isn't segfaulting.

I'm on PHP5.2.0 with libcurl/7.14.0 OpenSSL/0.9.8d zlib/1.2.3

( Not sure what's up with the RBL, email here is a little screwy. )


"Ron Croonenberg" wrote in message
news:45EED012.30203@depauw.edu...
> 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 -----
>
> (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 " >> 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, " >> $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" 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
> ============================================================ =====

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