Reading string from remote page

J

JoelWhitehouse

Hi! I want to write a script that will read a .php file on a remote
server and print to the current page a portion of the text contained in
the remote file. I am just wondering what the best method is for
reading from a file in this case - the file is only a few bytes long.
I've seen a tutorial or two that only tangentially addresses my
problem, and even then each one has varied greatly as to which object
they utilize.

Any ideas to get me started?

Many Thanks,

-Joel
 
R

Richard Cornford

Hi! I want to write a script that will read a .php file on a
remote server and print to the current page a portion of the
text contained in the remote file.

If "remote server" means a server that is not in the same domain as (or
a sub-domain of) the domain serving the page to the browser then normal
browser security will prevent any client-side mechanism from accessing
the content.
I am just wondering what the best method is for
reading from a file in this case - the file is only a
few bytes long.

Your own server could make the request to the "remote server" and pass
the result of request on, side-stepping the security restrictions.
I've seen a tutorial or two that only tangentially addresses
my problem, and even then each one has varied greatly as to
which object they utilize.

Any ideas to get me started?

Everything depends on what your are attempting to achieve, which is not
the simple matter of reading the output form a PHP script but includes
the context in which you want to do so and an explanation of why you
want to do so.

Richard.
 
J

JoelWhitehouse

Richard,

Thanks for your reply! I have the goal of serving dynamic content on
pages from a sever (A) that can serve little more than javascript. I
have a separate perl/php capable server (B) that I have written a few
server side scripts for, but I haven't found a way to display the
generated content on B through a page served by A. (The purpose is to
augment the capabilities of a blog account on server A.)

On A, I don't have the ability to make a request to B, parse the
result, and pass the rest on, since A is not server side capable. I
was hoping the process could be as simple as displaying pictures from a
separate server with the tag:
<IMG [...] src="http://www.remotedomain.com/pic.jpg">.

Following that model, I have already tried dynamically genereating a
".js" file and including it with the tag:
<SCRIPT [...] src="http://www.myBserver.com/generated.js">
Unfortunately, my blog account has a server side parser which
eliminates the src attribute of the SCRIPT tag if the src doesn't
belong to one of 12 approved domains (for security reasons.)

If I could use javascript to open a *text* file on a remote server,
read in a string, and print it, I wouldn't be including remote .js
files - I would just be displaying text from a remote site.

If that won't work, is there any way I could do a direct text include,
similar to the way I can use an IMG tag to display remote graphics?

Thanks again!

-Joel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,132
Latest member
TeresaWcq1
Top