1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Can you call an .asp web page into a php page using includes??

Discussion in 'PHP' started by Deliwasista, Apr 25, 2006.

  1. #1
    Hi there, thank you in advance for taking time to help here. I have a site which needs a page called into it from another url. I can get this working super well with this little script as long as the file url ends in .php or .html

    <?php include("http://www.thenameofsite.co.nz/thepageIwant.html"); ?>

    Sadly the page im calling in is a .asp page!
    <?php include("http://www.thenameofsite.co.nz/redir.asp?page=calendar&OID=O6S4vvxFLyen "); ?>

    and this doesnt work. My host tells me that the include function I have used is NOT good for calling a .asp file.
    SEMrush
    Does anybody know what I should use instead? can php do this?
     
    Deliwasista, Apr 25, 2006 IP
    SEMrush
  2. Caydel

    Caydel Peon

    Messages:
    835
    Likes Received:
    47
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Hate to tell you, but I don't think it's possible.

    Of course, perhaps another member can prove me wrong!
     
    Caydel, Apr 25, 2006 IP
  3. Deliwasista

    Deliwasista Member

    Messages:
    35
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    43
    #3
    oh bummer! thats not good news! Please someone prove Caydel wrong :) ps Caydel thanks heaps for replying! :)
     
    Deliwasista, Apr 25, 2006 IP
  4. woodside

    woodside Peon

    Messages:
    182
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #4
    As long as the site you are pulling it from can serve .asp pages, there is no reason this won't work.

    For example, this php page works fine:
     
    woodside, Apr 25, 2006 IP
    Caydel likes this.
  5. Caydel

    Caydel Peon

    Messages:
    835
    Likes Received:
    47
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Cool. Well, I guess I learn something new every day!
     
    Caydel, Apr 25, 2006 IP
  6. woodside

    woodside Peon

    Messages:
    182
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #6
    No problem. It's always nice to learn new tricks!
     
    woodside, Apr 25, 2006 IP
  7. digitalpoint

    digitalpoint Overlord of no one Staff

    Messages:
    38,287
    Likes Received:
    2,602
    Best Answers:
    460
    Trophy Points:
    710
    Digital Goods:
    29
    #7
    You can include the output of an ASP page just fine. Check the URL you are including though... doesn't seem to be valid when I try it.
     
    digitalpoint, Apr 25, 2006 IP
  8. Deliwasista

    Deliwasista Member

    Messages:
    35
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    43
    #8
    :) Have found an answer! the option using $asp=file does the trick - hope its ok to post it here as its from another forum - but figure that if you are reading this you are also stuck so matters not where the answer comes from!: see below:
    -----------------------------------------------------------------------
    Well if you think of it the only thing you will see is HTML and client side coding as everything else is Serverside so it should just be like including a HTML file in theory.. but i tryed and got this error..


    Warning: main(): Circular redirect, aborting. in /var/www/phpfreaks/includeasp.php on line 2

    Warning: main(http://www.pcservicecall.co.uk/Layout.aspx): failed to open stream: Success in /var/www/phpfreaks/includeasp.php on line 2

    Warning: main(): Failed opening 'http://www.pcservicecall.co.uk/Layout.aspx' for inclusion (include_path='/usr/share/php/') in /var/www/phpfreaks/includeasp.php on line 2

    just tryed fopen and file also gettin same erors.. tryed a diffrent address and this works

    <?php
    $asp=file('http://www.asp.net/Default.aspx');
    foreach ($asp as $line) {
    echo($line);
    }
    ?>

    however using include

    <?php
    include('http://www.asp.net/Default.aspx');
    ?>

    works also but took ALOT longer to load..
     
    Deliwasista, Apr 25, 2006 IP
  9. mad4

    mad4 Peon

    Messages:
    6,989
    Likes Received:
    493
    Best Answers:
    0
    Trophy Points:
    0
    #9
    As long as the url is valid then you can include it no matter whether its asp or whatever.

    Most problems with include and fopen are server firewall issues I find - ask your host.
     
    mad4, Apr 26, 2006 IP
  10. Deliwasista

    Deliwasista Member

    Messages:
    35
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    43
    #10
    just a wee note - the url I used in the first post is just an mock url as I wasnt sure if we were allowed to use actual site links. hence www."thenameofsite". The firewall issue sounds like it worth following up - I will check with my host (im assuming its my host I should ask not the host of the other web site im trying to include).

    This is working however (using my own url in place of asp.net of course)

    <?php
    $asp=file('http://www.asp.net/Default.aspx');
    foreach ($asp as $line) {
    echo($line);
    }
    ?>

    I dont know a lot about php - if this method is working is it an ok one to use? Or is it more accurate to use fopen or include?

    ps this is of little relevance to people who understand how all of this works but if you are in the same position as me you might find it useful to know that the owner of the other site gave me two url options (will replace the actual site name with "XXXXXX" in case its not wise to reveal it)

    this one only has the main page content on it and works using the $asp=file method:
    http://www.XXXXXX.co.nz/events/eventcalendar.asp?EName=&OrganizerID=O6S4vvxFLyen

    this one calls the entire page including the top header and side navigation and does NOT work using the above method:
    http://www.XXXXXX.co.nz/redir.asp?page=calendar&OID=O6S4vvxFLyen

    Once again thanks so much to you all with your suggestions!!
     
    Deliwasista, Apr 26, 2006 IP
  11. Deliwasista

    Deliwasista Member

    Messages:
    35
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    43
    #11
    And just when I thought I had cause to crack open a cold one and celebrate it seems that all the .gif images on the asp file dont show... Ive asked the asp site owner if they can use absolute paths to their images but apparently not - his "pages are based on a site variables file".

    any ideas as to how to beat this one would be appreciated! :)
     
    Deliwasista, Apr 26, 2006 IP
  12. mad4

    mad4 Peon

    Messages:
    6,989
    Likes Received:
    493
    Best Answers:
    0
    Trophy Points:
    0
    #12
    I use:
    ini_set (user_agent, "Your Name Here");
    ini_set (default_socket_timeout, "3");
    error_reporting(0);
    $theurl="http://www.theirdomain.com/page.aspx";
    $filestring=file_get_contents("$theurl") ;
    $filestring = str_replace("../images/", "http://www.theirdomain.com/images/", $filestring);
    echo "$filestring";
     
    PHP:
     
    mad4, Apr 27, 2006 IP
  13. Deliwasista

    Deliwasista Member

    Messages:
    35
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    43
    #13
    :)
    Hi Mad4, firstly thank you so much for your reply - I really appreciate it. Secondly Im a complete novice at php - and I suspect that my mark up is not at all correct. This is what Ive changed it to and of course its not working.

    <?php $asp=file('http://www.XXXXXX.co.nz/events/eventcalendar.asp?EName=&OrganizerID=O6S4vvxFLyen');
    foreach ($asp as $line) {
    echo($line);
    }

    ini_set (user_agent, "Your Name Here");ini_set (default_socket_timeout, "3");error_reporting(0);$theurl="http://www.XXXXXX.co.nz/events/eventcalendar.asp?EName=&OrganizerID=O6S4vvxFLyen";$filestring=file_get_contents("$theurl") ;$filestring = str_replace("../images/", "http://http://www.XXXXXX.co.nz/events/eventcalendar.asp?EName=&OrganizerID=O6S4vvxFLyen", $filestring);echo "$filestring";
    ?>

    I would love to do this right - any pointers would be most appreciated!.
    ps the other web owner tells me his images are stored here www.xxxxxx.co.nz\Images\ (I cant use the asp backslashes in the php can i?)
     
    Deliwasista, Apr 27, 2006 IP
  14. mad4

    mad4 Peon

    Messages:
    6,989
    Likes Received:
    493
    Best Answers:
    0
    Trophy Points:
    0
    #14
    ini_set (user_agent, "Your Name Here");
    ini_set (default_socket_timeout, "3");
    error_reporting(0);
    $theurl="http://www.XXXXXX.co.nz/events/eventcalendar.asp?EName=&OrganizerID=O6S4vvxFLyen";
    $filestring=file_get_contents("$theurl") ;
    $filestring = str_replace("../images/", "www.xxxxxx.co.nz/Images/", $filestring);
    echo "$filestring";
     
    PHP:
    What part exactly is not working?
     
    mad4, Apr 27, 2006 IP
  15. Deliwasista

    Deliwasista Member

    Messages:
    35
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    43
    #15
    I see I can drop the first bunch of code. So now it looks like your code above.

    This calls the text from the other sites page nicely - but the images are still showing as broken links.. any ideas?
     
    Deliwasista, Apr 27, 2006 IP
  16. mad4

    mad4 Peon

    Messages:
    6,989
    Likes Received:
    493
    Best Answers:
    0
    Trophy Points:
    0
    #16
    View the source and post the image url that is not working. Then try to get an image url that is working and post them both here for me to look at.
     
    mad4, Apr 27, 2006 IP
  17. TwistMyArm

    TwistMyArm Peon

    Messages:
    931
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    0
    #17
    This might seem like a silly question, but I thought I'd ask anyway...

    It seems you just want the page embedded in your page, it's nothing really to do with PHP or ASP. Is there a reason you don't want to just use an iframe for the page? If you did it that way, you wouldn't have any problems at all that I know of!
     
    TwistMyArm, Apr 27, 2006 IP
  18. mad4

    mad4 Peon

    Messages:
    6,989
    Likes Received:
    493
    Best Answers:
    0
    Trophy Points:
    0
    #18
    Iframes are fine......unless you need to get the content indexed by search engines or make some alterations to the content in some way.
     
    mad4, Apr 27, 2006 IP
  19. Deliwasista

    Deliwasista Member

    Messages:
    35
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    43
    #19
    Hi Mad4,

    this is where image C.gif lives
    http://www.enteronline.co.nz/images/C.gif

    When I view the source code for my page (holding the information called from enteronline) this is how it reads.
    <IMG SRC="../Images/C.gif">

    When I right click on the broken image link and read properties it reads this
    http://www.totalsport.co.nz/events/Images/C.gif

    It looks like its trying to pull the image from my directory and not from the other site.

    any ideas? and thank you soooo much for looking at this.. im quite keen to keep away from frames if I can.
     
    Deliwasista, Apr 27, 2006 IP
  20. mad4

    mad4 Peon

    Messages:
    6,989
    Likes Received:
    493
    Best Answers:
    0
    Trophy Points:
    0
    #20
    The str_replace is failing, probably due to the capital letter in the word 'Images'.

    Try this:

    $filestring = str_replace("../Images/", "http://www.enteronline.co.nz/images/", $filestring);
    PHP:
     
    mad4, Apr 28, 2006 IP