Forum Moderators: coopster

Message Too Old, No Replies

Include PHP-feed from other domain

Trying to merge partner content from other website into mine

         

didiparis

5:45 pm on Jun 19, 2005 (gmt 0)

10+ Year Member



A partner is suggesting I iframe their php-feed (http://www.partner.com/partner/feed.php) in an
HTML page on my website.

I do not want to use this option because the varying page length of the feed causes all kinds of usability issues.

I tried SSI but this can apparently only include files already in the same root as my HTML page. Here the feed page is coming from another domain.

What other options do I have to seemlessly incorporate their PHP-feed?

Thanks for any help and tips!

jatar_k

5:50 pm on Jun 19, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld didiparis,

it will really depend on what format it comes in, if it is an html page then you will need to frame it somehow.

If it is an RSS feed created by php then you will need to parse and display it, usually using xml parser functions.

there are a number of functions and libraries which may or may not be available to use for including, you can search fo rany of them at [php.net...]

include
require
fopen
fsockopen
curl libraries
xml libraries

then your standard frame or iframe solutions

sorry it isn't very specific there are many ways of doing this. Some of these functions may not be available on shared hosts.

didiparis

7:21 pm on Jun 19, 2005 (gmt 0)

10+ Year Member



Thank you for the welcome!

It is not a rss-feed but many content pages that i recieve from the partner. To have my website's header and footer above and under the content they suggest iFrame-ing.

So this seems the only solution?! ... yuck, yuck and triple yuck...

The user will be browsing inside the iframe: url of my page stays the same, my page doesn't reload to top on every click inside the iframe...

davelms

7:30 pm on Jun 19, 2005 (gmt 0)

10+ Year Member



Are they "whole" pages, including headers, meta tags, etc or just body content? Why not grab the content using something like file_get_contents("http://www.partner.com/partner/feed.php"); and either strip off the headers of just output the contents?

didiparis

7:40 pm on Jun 19, 2005 (gmt 0)

10+ Year Member



They are whole pages (like a complete website within an iframe):

How do I get my header and footer on top and under these pages of variable size?..

[edited by: jatar_k at 4:32 pm (utc) on June 20, 2005]
[edit reason] no urls thanks [/edit]

didiparis

8:05 pm on Jun 19, 2005 (gmt 0)

10+ Year Member



I found this cached on Google. It matches well my iframe problem - only I don't understand how to build the solution... - help please?...

=====QUOTE============

What started out to be a simple quest has ended in disappointment. All I wanted to do is solve the riddle of how to resize an iframe based on its content when that content is loaded from a page in another domain that cannot be modified in the source file. A client side approach seemed like the logical choice for efficiency but after several days of Internet browsing and trying many different conceptual approaches I am convinced that this cannot be done with any client side only technique.

The Problem - It ain't easy
The problem is embedded in the security design of the DOM. As Netscape puts it "... When loading a document from one origin, a script loaded from a different origin cannot get or set certain predefined properties of certain browser and HTML objects in a window or frame." And origin is pretty tightly defined as protocol://host[:port], somewhat loosely referred to as "the domain" (unless document.domain is used to set a value that is a suffix of the current domain). So even though the foreign (different origin) document is rendered in the iframe of the current document, it is still on the other side of the security barrier. By experimentation, the barrier is bi-directional.

And, as document object element properties are on the list of properties subject to origin check, the short version is that it cannot be done this way. Several posters have said this, too. I don't like absolute statements, but there it is.

The Concept - The Only Way?
The only way I have been able to achieve the goal is with a server side approach. Conceptually, with a php script running as [myserver.com...] and a user clicks on a link that specifies [myserver.com...]

Mainpage.php includes the javascript callback function resizeFrame(), html

====END QUOTE===========

davelms

8:14 pm on Jun 19, 2005 (gmt 0)

10+ Year Member



#1 I'd output my header.
#2 I'd use file_get_contents to get the feeder page into my PHP script. I'd strip off the headers and get the page just as the body contents. Couple of ways spring to mind, but there may well be better ways (probably using reg ex which I know little about). Either explode() or substr() functions would do it for me. I'd output the page as I've amended it.
#3 Then I'd output my footer.

And I'd not go anywhere near an iframe.

didiparis

9:23 pm on Jun 19, 2005 (gmt 0)

10+ Year Member



Thank you very much!

Are you sure that, as a user navigates the "imported" partner content, my header and footer will always be automatically added to EVERY content page?

If so, could someone please translate this solution into copy & pastable code? It's very frustrating to be looking at the solution without being able to implement it :(

I am sure many others would love to use this solution!