prosper99 Posted February 16, 2010 Share Posted February 16, 2010 Hello Everyone, Looking for 2 methods to opening a non local url that is formed from a php script. 1st method is to open a URL on the local server where PHP is running, 2nd method is to open a URL on a remote PHP proxy server. In both cases just need it to open and close. Can PHP provide this functionality? Thank You. Rob. Link to comment https://forums.phpfreaks.com/topic/192311-open-a-url-server-side-with-php/ Share on other sites More sharing options...
samtwilliams Posted February 16, 2010 Share Posted February 16, 2010 Hi Rob, Have you looked at the cURLLib? http://curl.haxx.se/ I am sure you can achieve your goal with this or maybe look at the fopen() functions. Hope this helps Sam Link to comment https://forums.phpfreaks.com/topic/192311-open-a-url-server-side-with-php/#findComment-1013395 Share on other sites More sharing options...
prosper99 Posted February 21, 2010 Author Share Posted February 21, 2010 Thank You, yes CURL works for me for opening URL's locally. But can't seem to find any examples of CURL opening a URL on a remote PHP proxy, ie submit a url to the proxy and have it open it... <?php function get_data($url) { $ch = curl_init(); $timeout = 5; $userAgent="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)"; curl_setopt($ch, CURLOPT_USERAGENT, $userAgent); curl_setopt($ch, CURLOPT_FAILONERROR, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_AUTOREFERER, true); curl_setopt($ch, CURLOPT_TIMEOUT, 10); curl_setopt($ch,CURLOPT_URL,$url); curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout); $data = curl_exec($ch); curl_close($ch); return $data; } $returned_content = get_data('http://anyphpproxy.com'); echo $returned_content; ?> Link to comment https://forums.phpfreaks.com/topic/192311-open-a-url-server-side-with-php/#findComment-1015494 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.