Jump to content

how to check if link is valid? regex maybe?


pouncer

Recommended Posts

Not all the rss and xml feeds end on those extensions.

 

You could easily create an index.php sending out an rss or xml header and rss/xml.

Then the name would be something not ending in any extension or .php.

(Can come up with other exceptions as well, but you're not likely to come across those situations).

 

Based on the url itself you wont be able to tell, you'll need to visit the page with php itself and either check the headers, or it's content.

Which might not be possible depending on your host.

 

Like I said, you can't rely on the format of the URL to determine if something is an RSS feed or not.

A regular expression would do you no good, unless you're using it on the loading the page trough say.. curl and then applying it on the content or response header.

 

Before we get into that however you may want to check if your host even supports it and if it does if it's without limits.

The (free) host I use for example states in the EULA that I can only use curl once every hour.

 

To see if it's supported simply use a phpinfo file and ctrl+f for curl.

<?php
  phpinfo();
?>

If it's not supported you'll just have to 'believe' the user, perhaps post some link to an explanation of what RSS and XML look like.

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.