gameduels Posted April 22, 2009 Share Posted April 22, 2009 Is there a way you can include a URL into a web page ? this is the game tracker i want to include http://beta.socom.com/en-us/Blog/Ticker i cant figure it out i know you can thanks everyone Quote Link to comment https://forums.phpfreaks.com/topic/155193-php-help-i-want-to-include-a-url/ Share on other sites More sharing options...
ILMV Posted April 22, 2009 Share Posted April 22, 2009 What do you mean include it, you can put it in an iframe? Quote Link to comment https://forums.phpfreaks.com/topic/155193-php-help-i-want-to-include-a-url/#findComment-816377 Share on other sites More sharing options...
JonnoTheDev Posted April 22, 2009 Share Posted April 22, 2009 using include() as long as allow_url_fopen is enabled in your php.ini configuration. http://uk.php.net/manual/en/function.include.php Quote Link to comment https://forums.phpfreaks.com/topic/155193-php-help-i-want-to-include-a-url/#findComment-816378 Share on other sites More sharing options...
gameduels Posted April 22, 2009 Author Share Posted April 22, 2009 i mean i want to display it into my web site. I cant get it to display . I tryed everything i can think of lol Quote Link to comment https://forums.phpfreaks.com/topic/155193-php-help-i-want-to-include-a-url/#findComment-816380 Share on other sites More sharing options...
tang Posted April 22, 2009 Share Posted April 22, 2009 Don't use include, it has security implications. Either put it in an iframe (easy but probably not the "best" way to do it) or grab the contents with file_get_contents($url), parse it then include it in your page. Quote Link to comment https://forums.phpfreaks.com/topic/155193-php-help-i-want-to-include-a-url/#findComment-816398 Share on other sites More sharing options...
JonnoTheDev Posted April 22, 2009 Share Posted April 22, 2009 file_get_contents($url) is slow. If you want to read the page and extract parts from it then the best method is CURL. Read the examples http://uk.php.net/manual/en/book.curl.php Quote Link to comment https://forums.phpfreaks.com/topic/155193-php-help-i-want-to-include-a-url/#findComment-816405 Share on other sites More sharing options...
gameduels Posted April 22, 2009 Author Share Posted April 22, 2009 well im kinda a new at php idk if anyone would show me a code so i can under stand im learning haha Quote Link to comment https://forums.phpfreaks.com/topic/155193-php-help-i-want-to-include-a-url/#findComment-816426 Share on other sites More sharing options...
ILMV Posted April 22, 2009 Share Posted April 22, 2009 <?php // create curl resource $ch = curl_init(); // set url curl_setopt($ch, CURLOPT_URL, "beta.socom.com/en-us/Blog/Ticker"); //return the transfer as a string curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // $output contains the output string $output = curl_exec($ch); // close curl resource to free up system resources curl_close($ch); ?> try that Quote Link to comment https://forums.phpfreaks.com/topic/155193-php-help-i-want-to-include-a-url/#findComment-816434 Share on other sites More sharing options...
tang Posted April 22, 2009 Share Posted April 22, 2009 file_get_contents($url) is slow. If you want to read the page and extract parts from it then the best method is CURL. Read the examples http://uk.php.net/manual/en/book.curl.php I scoffed at that when I saw it, didn't think there would be much difference but I've done some tests and CURL is consistently faster over file_get_contents(). Quote Link to comment https://forums.phpfreaks.com/topic/155193-php-help-i-want-to-include-a-url/#findComment-816700 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.