Jump to content

Recommended Posts

Hi,

 

I'm quite a novice with php, but I have had some prior success.

 

I currently stumped over an issue using include.  I have also tried require, fopen, file_get_contents too.

 

I have the following code:

 

<html>

<body>

 

<?php

$page = "http://hopfeed.com/serv/hopFeedServ.htm";

echo $page;

include ($page);

?>

 

</body>

</html>

 

if I make the page variable equal google.com or another domain it works, but not when I use the above code.  The browser page echos the page variable and then just sits there, loading indefinitely.

 

The page that I'm loading isn't straight html, there is stuff going on in the background as you can pass it variables see below:

 

http://www.hopfeed.com/serv/hopFeedServ.htm?type=IFRAME&fillAllSlots=true&align=LEFT&headerText=My%20Ads%20Here&height=400&width=150&linkFontHoverColor=%233300FF&linkFontColor=%233300FF&backgroundColor=%23FFFFFF&font=Verdana%2C%20Arial%2C%20Helvetica%2C%20Sans%20Serif&fontSize=9pt&fontColor=%23000000&rows=3&cols=1&keywords=business&tid=abc123&affiliate=cashexits&cellpadding=5

 

However, the page that is returned using the above URL has html source.

 

I'm puzzled by this and it is beyond my php skills.

 

Any help would be greatly appreciated.

 

Thanks,

 

bonnag.

 

 

Well, one thing I can see from the actual url for the page is that it's actually designed to go in an iframe (the IFRAME value that's in the type parameter). I'm guessing that the failure to load is on hopfeed's end as a security precaution and that you're not likely to be able to do what you want to do.

 

You should really be using an iframe for it or seeing if they've got any other specific parameterised URLs that don't rely on an iframe type to work.

 

 

Actually it is the setting on your server. You or admin can enable PHP to be able to include or fopen or whatever remote files. For security reasons it might be disabled by default.

 

If it is disabled they may allow you to use curl that does the same thing in a sense.

bothwell,

 

The link itself opens, even though it contains IFRAME in it.  I was under the impression that if I can open it in a browser, that I could use in with a php include.  Is this assumption incorrect?

 

Others,

 

Thanks for your suggestions but other URL's work, such as google.com, so as far as I know all the settings are in order.

 

Any other ideas?

 

Thanks,

 

bonnag

It could be that the site in question checks the user agent string, and discards requests from "PHP" (the default user agent string when retrieving external pages with PHP). You can set the user agent string PHP uses with

 

ini_set('user_agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; da; rv:1.9) Gecko/2008052906 Firefox/3.0');

 

at the top of your script. May be a bit immoral, but that's up to you to decide.

It could be that the site in question checks the user agent string, and discards requests from "PHP" (the default user agent string when retrieving external pages with PHP). You can set the user agent string PHP uses with

 

ini_set('user_agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; da; rv:1.9) Gecko/2008052906 Firefox/3.0');

 

at the top of your script. May be a bit immoral, but that's up to you to decide.

 

Thanks for the suggestion, but that doesn't work either!

I just can't figure this out....

 

bonnag.

First off, include is used when you want to parse the content in the file.  You're better off/safer with file_get_contents.

 

 

Anyway, chances are, there is an error and it's just not showing.

 

At the top of the page, add:

 

ini_set('display_errors', '1');

error_reporting(E_ALL);

Well, it definitely has something to do with something on your end.

 

 

<?php
echo file_get_contents('http://hopfeed.com/serv/hopFeedServ.htm');

 

 

Works as expected for me.

 

Corbin,

 

Thanks for doing that.  That is a great help.

I'll keep plugging at it.

 

bonnag

I've changed the code to the following and all that appears in the browser is "1"!

 

<html>

<body>

<?php

echo 1;

$page = file_get_contents('http://hopfeed.com/serv/hopFeedServ.htm');

echo 2;

var_dump($page);

echo 3;

?>

</body>

</html>

 

Is there script I could run to get a bunch of variables as to what is turn on and off on the server that might shead some light on this?

 

Thanks,

 

bonnag

Yes,

 

<?php
phpinfo();
?>

 

"allow_url_fopen" should be On in order for your script to work. If you've got cURL installed, you could try that instead. This is similar to echoing file_get_contents(), just using cURL:

 

<?php
$c = curl_init();
curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
curl_setopt($c, CURLOPT_URL, 'http://hopfeed.com/serv/hopFeedServ.htm');
$contents = curl_exec($c);
curl_close($c);
echo $contents;
?>

thebadbad,

 

Thanks.

 

Curl and allow_url_fopen are both on and work with other domains.

Could it be that the server that I am trying to access is denying the requests.

I am with Hostgator so I wouldn't have thought their IP's were bad.

 

Thanks,

 

bonnag

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.