LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-24-2004, 02:51 AM   #1
antony_csf
Member
 
Registered: Jun 2004
Posts: 51

Rep: Reputation: 15
how to use php open and url


hi all,

I have a problem on using php to open a url.
it is possible to use php to open the url and do the login process on other site?

it yes ! please give me some advice!!

many thx ~~!
 
Old 09-24-2004, 09:39 AM   #2
lappen
Member
 
Registered: Aug 2003
Location: Sweden
Posts: 83

Rep: Reputation: 15
I am not sure but I think curl would do the trick
http://www.php.net/curl
 
Old 09-26-2004, 09:04 PM   #3
antony_csf
Member
 
Registered: Jun 2004
Posts: 51

Original Poster
Rep: Reputation: 15
sorry If I do not use curl function, is it possible to use the following code to open the url???

<?php

$my_file = file("http://www.google.com/");

$fp = fopen($my_file, "r") or die("OPEN");
while (! feof($fp)){
fread($fp, 1024) or die("READ");
}
fclose($fp) or die("CLOSE");

?>


after I run the above code I receive the following message :

Warning: file(http://www.google.com/): failed to open stream: Bad file descriptor in c:\program files\easyphp1-7\www\cmd\grabber.php on line 3
OPEN

what 's wrong ??

 
Old 09-26-2004, 09:43 PM   #4
lappen
Member
 
Registered: Aug 2003
Location: Sweden
Posts: 83

Rep: Reputation: 15
try

Code:
<?php
        $fp = fopen('http://www.google.com', 'r');

        $content = '';

        while ($l = fread($fp, 1024)) $content .= $l;
        fclose($fp);
        echo $content;
?>
 
Old 09-26-2004, 11:01 PM   #5
antony_csf
Member
 
Registered: Jun 2004
Posts: 51

Original Poster
Rep: Reputation: 15
I have try the code but I receive the following massage:

Code:
<?php
        $fp = fopen('http://www.google.com', 'r');

        $content = '';

        while ($l = fread($fp, 1024)) $content .= $l;
        fclose($fp);
        echo $content;
?>

Warning: fopen(http://www.google.com): failed to open stream: Bad file descriptor in c:\program files\easyphp1-7\www\cmd\grabber.php on line 2

Warning: fread(): supplied argument is not a valid stream resource in c:\program files\easyphp1-7\www\cmd\grabber.php on line 6

Warning: fclose(): supplied argument is not a valid stream resource in c:\program files\easyphp1-7\www\cmd\grabber.php on line 7

is it something wrong on my php setting ???
 
Old 09-26-2004, 11:20 PM   #6
lappen
Member
 
Registered: Aug 2003
Location: Sweden
Posts: 83

Rep: Reputation: 15
; Whether to allow the treatment of URLs (like http:// or ftp://) as files.
allow_url_fopen = On


Can't think of anything else
 
Old 09-27-2004, 12:19 AM   #7
antony_csf
Member
 
Registered: Jun 2004
Posts: 51

Original Poster
Rep: Reputation: 15
I find the php.ini the value is set to on

allow_url_fopen = On

anyone can help me ??
 
Old 09-27-2004, 12:54 AM   #8
antony_csf
Member
 
Registered: Jun 2004
Posts: 51

Original Poster
Rep: Reputation: 15
hi!! I think it may be the problem on my PC error!!

I am now test the code on the server side it works!!

many thx you !!! thx ~~!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
open a URL from shell plisken Linux - General 3 11-10-2005 01:43 AM
open a url in c++ bertlef Programming 2 01-07-2005 04:27 PM
It's so slow to open a url j.vilon Debian 12 10-04-2004 12:32 PM
Getting the url with PHP linux_pioneer Linux - General 2 06-20-2004 02:08 PM
PHP Url? HappyDude Programming 2 09-20-2003 04:20 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:25 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration