We need the user to be able to enter URLs in our media section . However since users can make mistakes in entering the URLs , we need to ensure that the URLs are valid flickr URLs . Valid URL eg : http://www.flickr.com/photos/53067560@N00/sets/72157606175084388/
Invalid URL eg : http://www.flickr.com/photos/53067560@N00/sets/12345/
Flickr offers API services , but I could not find one that would validate a URL .
The easiest way would be to make a HTTP HEAD request to the url, which would mean the URL is valid if it returns a HTTP response code of 200.
You could also use regex to ensure that it matches the expected pattern, which would possibly cut down the amount of requests you would have to make.
You could make an http HEAD request to the URL and check the http response code. Any response code greater than or equal to 200 and less than 300 is ok. In all likelyhood good URLs will return 200 code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With