PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
deostroll
Forum Newbie
Posts: 7 Joined: Sat Dec 12, 2009 8:10 am
Post
by deostroll » Sat Dec 12, 2009 8:19 am
hi,
totally new to php. Need to know how to download a web page via php, and display the response onto the screen. I've tried the following thread, but it didn't work...
viewtopic.php?f=1&t=104054&p=556715
Here is my php code:
Code: Select all
<?php
/*
$handle = fopen("http://www.example.com","r");
$txt = fread($handle, "15");
echo $txt;
fclose($handle);
*/
#$response = http_get("http://www.example.com/", array("timeout"=>1), $info);
#$response = http_request(0,"www.example.com");
//print_r($info);
//print_r($response);
//echo $response;
#echo "this is the end";
echo "hello world"
echo 'test';
$r = new HttpRequest('http://example.com/form.php', HttpRequest::METH_POST);
echo 'test';
$r->setOptions(array('cookies' => array('lang' => 'de')));
$r->addPostFields(array('user' => 'mike', 'pass' => 's3c|r3t'));
try
{
echo $r->send()->getBody();
}
catch (HttpException $ex) { echo $ex; }
?>
Basically tried everything in there...Running php of LAMP...
Darhazer
DevNet Resident
Posts: 1011 Joined: Thu May 14, 2009 3:00 pm
Location: HellCity, Bulgaria
Post
by Darhazer » Sun Dec 13, 2009 3:29 pm
Did you tried with cURL?
greyhoundcode
Forum Regular
Posts: 613 Joined: Mon Feb 11, 2008 4:22 am
Post
by greyhoundcode » Sun Dec 13, 2009 3:38 pm
I assume you've tried a simple:
Code: Select all
echo file_get_contents('http://www.yahoo.com');
And if that does not work, are you able to adjust server settings etc so that it would work?
greyhoundcode
Forum Regular
Posts: 613 Joined: Mon Feb 11, 2008 4:22 am
Post
by greyhoundcode » Mon Dec 14, 2009 9:26 am
Does the Java app work as expected when called directly? What if you place the Java filename inside the URL, like:
http://localhost:8081/ myJavaApp.jsp ?language=en&text=this%20is%20an%20test
deostroll
Forum Newbie
Posts: 7 Joined: Sat Dec 12, 2009 8:10 am
Post
by deostroll » Mon Dec 14, 2009 2:51 pm
okay the issue is resolved...it is with the way the java application is actually supposed to execute...