rckehoe Posted April 24, 2009 Share Posted April 24, 2009 Hello, I am not sure where to start looking for this, but I was wondering how I would obtain the header information of a specified URL using PHP... For example. I am having users specify their XML feed URL and I want to be able to check the URLS data-type and make sure that it is a XML feed... I don't want to use the domain extension, because sometimes it will be a PHP extension or an ASP extenstion... get my drift? Link to comment https://forums.phpfreaks.com/topic/155555-php-header-question/ Share on other sites More sharing options...
jackpf Posted April 24, 2009 Share Posted April 24, 2009 I've never come across a method of gathering headers myself... (not saying it isn't possible, but I haven't heard of it). Can't you just demand that the xml file has <?xml version="1.0" encoding="utf-8"?> at the top? Most should anyway tbh, if they're valid xml. Link to comment https://forums.phpfreaks.com/topic/155555-php-header-question/#findComment-818668 Share on other sites More sharing options...
Mchl Posted April 24, 2009 Share Posted April 24, 2009 Are you looking for get_headers function? Link to comment https://forums.phpfreaks.com/topic/155555-php-header-question/#findComment-818677 Share on other sites More sharing options...
jackpf Posted April 24, 2009 Share Posted April 24, 2009 Well I'll be damned. Link to comment https://forums.phpfreaks.com/topic/155555-php-header-question/#findComment-818680 Share on other sites More sharing options...
gffg4574fghsDSGDGKJYM Posted April 24, 2009 Share Posted April 24, 2009 You want to get the Content-Type of a HTTP header of a URL ? Like that : http://web-sniffer.net/ You can use cUrl to do that like this : <?php $timeout = 10; $ch = curl_init("http://www.somesite.com/somepage.php"); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; en) Opera 9.64'); curl_setopt($ch, CURLOPT_HEADER, true); $output = curl_exec($ch); curl_close($ch); echo $output; ?> Link to comment https://forums.phpfreaks.com/topic/155555-php-header-question/#findComment-818683 Share on other sites More sharing options...
rckehoe Posted April 29, 2009 Author Share Posted April 29, 2009 the get_headers function works great. Thank you. Link to comment https://forums.phpfreaks.com/topic/155555-php-header-question/#findComment-822181 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.