Jump to content

PHP Header question


rckehoe

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.