CrossX Posted June 17, 2008 Share Posted June 17, 2008 I'm trying to curl this peace of code... but nothing.. some can help me? $adr = 'http://www.exmp.com'; if ($html = file_get_contents($adr)) { if ..... .... Link to comment https://forums.phpfreaks.com/topic/110655-curl-the-file_get_contents/ Share on other sites More sharing options...
trq Posted June 17, 2008 Share Posted June 17, 2008 Sorry, exactly what do you meen? Link to comment https://forums.phpfreaks.com/topic/110655-curl-the-file_get_contents/#findComment-567674 Share on other sites More sharing options...
CrossX Posted June 17, 2008 Author Share Posted June 17, 2008 Instead of: file_get_contents on the script above Use this: $ch = curl_init(); $timeout = 5; // set to zero for no timeout curl_setopt ($ch, CURLOPT_URL, '$adr'); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout); $file_contents = curl_exec($ch); curl_close($ch); Link to comment https://forums.phpfreaks.com/topic/110655-curl-the-file_get_contents/#findComment-567679 Share on other sites More sharing options...
trq Posted June 17, 2008 Share Posted June 17, 2008 Are you answering your own question now or what? Link to comment https://forums.phpfreaks.com/topic/110655-curl-the-file_get_contents/#findComment-567682 Share on other sites More sharing options...
CrossX Posted June 17, 2008 Author Share Posted June 17, 2008 no it wont works?! i don't know how to put both? Link to comment https://forums.phpfreaks.com/topic/110655-curl-the-file_get_contents/#findComment-567688 Share on other sites More sharing options...
DarkWater Posted June 18, 2008 Share Posted June 18, 2008 Your question makes no sense. Please be specific and don't make incoherent sentences. =/ Link to comment https://forums.phpfreaks.com/topic/110655-curl-the-file_get_contents/#findComment-567704 Share on other sites More sharing options...
CrossX Posted June 18, 2008 Author Share Posted June 18, 2008 In a measure to improve security, my host has disabled the PHP option allow_url_fopen. and the alternative for me is tu use cURL Instead of use "file_get_contents" i have to find another method! my function is: function my_external_link($id, $redirect = false) { $url = 'http://www.example.com/video?f='.$id; if ($html = file_get_contents($url)) { if (preg_match('/\/player2\.swf\?video_id=.*?&t=(.*?)"/', $html, $match)) { $url = 'http://youtube.com/get_video.php?video_id='.$id.'&t='.$match[1]; if ($redirect && $redirected_url = get_redirected_url($url)) { $url = $redirected_url; } return $url; } } return false; } but with; file_get_contents im having this error: URL file-access is disabled in the server configuration in did someone understand me? Link to comment https://forums.phpfreaks.com/topic/110655-curl-the-file_get_contents/#findComment-567728 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.