Solved

call asp URL in php page (includes?)

Posted on 2007-04-04
10
319 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
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

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…
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

785 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