Solved

call asp URL in php page (includes?)

Posted on 2007-04-04
10
317 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
Comment Utility

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
Comment Utility
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
Comment Utility
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
 
LVL 15

Expert Comment

by:babuno5
Comment Utility
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
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 11

Expert Comment

by:f_o_o_k_y
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction Many web sites contain image galleries; a common design for these galleries includes a page with a collection of thumbnail images.  You can click on each of the thumbnail images to see the larger version of the image.  This is easily i…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

771 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now