Solved

call asp URL in php page (includes?)

Posted on 2007-04-04
10
320 Views
Last Modified: 2007-12-19
is there anway i can call this

http://physfindweb.beryl.net/SearchForm.aspx?ClientID=3225

in a php includes? or some such thing - i want to show it on a php page, fit it into my site's look/feel.

thanks!
0
Comment
Question by:phillystyle123
  • 5
  • 3
  • 2
10 Comments
 
LVL 11

Expert Comment

by:f_o_o_k_y
ID: 18856409

Maybe something like this:

HTML code:

<iframe src="http://physfindweb.beryl.net/SearchForm.aspx?ClientID=3225"   frameborder="1">
    ups...Your browser does not support frames
</iframe>
0
 
LVL 15

Expert Comment

by:babuno5
ID: 18856934
or may be you can try
$tmp_str_contents = file_get_contents("http://physfindweb.beryl.net/SearchForm.aspx?ClientID=3225");
All the contents from the remote site will be available in the variable and then you can print it out
0
 
LVL 11

Expert Comment

by:f_o_o_k_y
ID: 18858005
babuno5:
There mght be problem when URL is invalid or server is busy.

But if you want to do something with the content for example change or just include HTML inside your code then you must do as babuno5 said.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 15

Expert Comment

by:babuno5
ID: 18859595
yes the problem can though be handled with a small check
$tmp_str_contents = file_get_contents("http://physfindweb.beryl.net/SearchForm.aspx?ClientID=3225");
if($tmp_str_contents === false)
{
//there was some problem making a call and may be show some custom error message
}
0
 

Author Comment

by:phillystyle123
ID: 18859902
thanks - what am i doing wrong here (i'm getting "application not available - but if i open the link in it's own window, it works fine")

<?php $tmp_str_contents = file_get_contents("http://physfindweb.beryl.net/SearchForm.aspx?ClientID=3225");
if($tmp_str_contents === false)
{
//there was some problem making a call and may be show some custom error message
}?>

<?php echo "$tmp_str_contents"; ?>
0
 
LVL 11

Expert Comment

by:f_o_o_k_y
ID: 18862893
Hello,
Dont kow why but it seems to be a problem with IIS on which the page is running.
I found 2 workarounds but only one i could test:
1. Require PECL

<?php
$body = http_parse_message(http_get($url))->body;
?>

2. Require much more code but works and does not require any additional things:
You can use this (tested):
This code sends HTTP request just like you would use telnet.

<?php

$sock = fsockopen("tcp://physfindweb.beryl.net", 80, $errno, $errstr, 30);

if (!$sock) die("$errstr ($errno)\n");



fwrite($sock, "GET /SearchForm.aspx?ClientID=3225 HTTP/1.0\r\n");

fwrite($sock, "Host: physfindweb.beryl.net\r\n");

fwrite($sock, "User-Agent: PHP \r\n");

fwrite($sock, "Accept: */*\r\n");

fwrite($sock, "\r\n");

fwrite($sock, "\r\n");





$headers = "";

while ($str = trim(fgets($sock, 4096)))

  $headers .= "$str\n";





$body = "";

while (!feof($sock))

  $body .= fgets($sock, 4096);





echo $body;



fclose($sock);



?>
0
 

Author Comment

by:phillystyle123
ID: 18865601
hi fooky - this works but:

1. it takes a while to load

2. the search results page goes to the main URL i.e.

http://mysite.com/SearchForm.aspx?ClientID=3225 - and that page doesn't exist.

i'm putting this at the top of the page:

<?php
$body = "http_parse_message(http_get($url))->body";
?>

and this in the body:

<?php

$sock = fsockopen("tcp://physfindweb.beryl.net", 80, $errno, $errstr, 30);

if (!$sock) die("$errstr ($errno)\n");



fwrite($sock, "GET  http://physfindweb.beryl.net/SearchForm.aspx?ClientID=3225 HTTP/1.0\r\n");

fwrite($sock, "Host: physfindweb.beryl.net\r\n");

fwrite($sock, "User-Agent: PHP \r\n");

fwrite($sock, "Accept: */*\r\n");

fwrite($sock, "\r\n");

fwrite($sock, "\r\n");





$headers = "";

while ($str = trim(fgets($sock, 4096)))

  $headers .= "$str\n";





$body = "";

while (!feof($sock))

  $body .= fgets($sock, 4096);





echo $body;



fclose($sock);



?>

(notice i changed the GET url to absolute but still getting the same result
0
 
LVL 11

Expert Comment

by:f_o_o_k_y
ID: 18866390
No no no :)

its a complete solution but require PECL
<?php
$body = "http_parse_message(http_get($url))->body";
?>

THIS is also a complete solution:
Dont use them together


0
 

Author Comment

by:phillystyle123
ID: 18866580
thanks fooky but still getting the same result - the URL:

http://goodsam.org/doctors/test.php

notice - takes a while to load and then when i submit the form i get my error page - note, i'm using solution 2 and NOT solution 1 - thanks again for your help with this!
0
 
LVL 11

Accepted Solution

by:
f_o_o_k_y earned 125 total points
ID: 18870227
Heh :) It's very simple answer why it's not working properly. When you submit form there is no page which can handle the request.
After you include form into your page you need to procede the request.

If you only want other serwer to answer for this question try using:
<iframe src="http://physfindweb.beryl.net/SearchForm.aspx?ClientID=3225"   frameborder="1">
    ups...Your browser does not support frames
</iframe>

Or catch the POST data and submit them by using fwirte to the orginal server and then proceed with another response.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.

735 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question