how to validate a rss feed address

Please support our PHP advertiser: 50% off 6 Months Dedicated Server Hosting from 1&1!
Reply

Join Date: Jun 2009
Posts: 18
Reputation: ym_chaitu is an unknown quantity at this point 
Solved Threads: 0
ym_chaitu ym_chaitu is offline Offline
Newbie Poster

how to validate a rss feed address

 
0
  #1
Nov 21st, 2009
Hai
i am building a site for validation of the RSS feeds and adding it in the database.
When a user enters a rss web address i need to validate the address and if it contains a rss then i need to enter it into the site or else i need to mention a message..
how do i do it.
i think the easy way is to pass the feed address to this address http://validator.w3.org/feed/check.cgi?url=

but how can i check what result is it giving..
do any one have an idea or else if u have any validation things available. kindly help me out..
  1. <html>
  2. <body>
  3. <form action="subscription.php" method="post">
  4. <b>Add New Subscription URL :</b><input name="subscr" value="" size="50">
  5. <input type="submit" name="submit" value="Add" />
  6. </form>
  7. </body>
  8. </html>
  9.  
  10. <?php
  11. //include("login.php");
  12. include("access.php");
  13. mysql_select_db($dbname);
  14. if (isset($_COOKIE['user']))
  15. {
  16. echo "Welcome $_COOKIE[user]<br>";
  17. $username="$_COOKIE[user]";
  18. //echo "<p>$username</p>";
  19. $query = mysql_query("SELECT email,password FROM userlogin WHERE username = '$username'") or die(mysql_error());
  20. $data = mysql_result($query,0);
  21. //echo $data;
  22. }
  23. else
  24. {
  25. echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"1; URL=login.php\">";
  26. }
  27.  
  28. $subscr=$_REQUEST['subscr'];
  29. if($subscr)
  30. {
  31. //url validation
  32.  
  33. if (preg_match('|^http(s)?://[a-z0-9-]+(.[a-z0-9-]+)*(:[0-9]+)?(/.*)?$|i', $subscr))
  34. {
  35. //print "$subscr url OK.";
  36. mysql_select_db($dbname);
  37. $re=mysql_query("select * from usubs where url='$subscr'");
  38. $rows=mysql_num_rows($re);
  39. if($rows==0)
  40. {
  41. mysql_query("Insert into usubs(email,url) values('$data','$subscr')");
  42. //echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"1; URL=all.html\">";
  43. }
  44. else
  45. {
  46. echo "The $subscr url already exists with your login";
  47. //echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"1; URL=subscription.php\">";
  48. }
  49.  
  50. }
  51. else
  52. {
  53.  
  54. print "$subscr url not valid!";
  55. }
  56. }
  57. else
  58. {
  59. //echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"1; URL=subscription.php\">";
  60. //echo("$subscr");
  61. }
  62. ?>

this is my code
presently i am using the regular expression of the website address but how do i use it to verify the rss feed address..
as the present one is validating the www.google.com also as a valid feed..
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 146
Reputation: robothy is an unknown quantity at this point 
Solved Threads: 20
robothy robothy is offline Offline
Junior Poster
 
0
  #2
Nov 21st, 2009
Hey,

Could you not use cURL to read the response from the URL supplied, and then check that it starts with something like the following using regular expressions?

  1. <?xml version="1.0" encoding="utf-8"?>
  2.  
  3. <rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">

R
Last edited by robothy; Nov 21st, 2009 at 2:50 pm.
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 340
Reputation: SKANK!!!!! is an unknown quantity at this point 
Solved Threads: 3
SKANK!!!!!'s Avatar
SKANK!!!!! SKANK!!!!! is offline Offline
Posting Whiz
 
0
  #3
Nov 21st, 2009
do an iframe folks!
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 146
Reputation: robothy is an unknown quantity at this point 
Solved Threads: 20
robothy robothy is offline Offline
Junior Poster
 
0
  #4
Nov 22nd, 2009
Oh and by the way, if you want to do redirects within PHP, try using the Header method instead. E.g.

  1. header('Location: target.html');

R.
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 18
Reputation: ym_chaitu is an unknown quantity at this point 
Solved Threads: 0
ym_chaitu ym_chaitu is offline Offline
Newbie Poster
 
0
  #5
Nov 23rd, 2009
i dont have curl installed in my php..Is there any way to do it without using curl.
Reply With Quote Quick reply to this message  
Join Date: Feb 2010
Posts: 2
Reputation: Canaan_moore is an unknown quantity at this point 
Solved Threads: 0
Canaan_moore Canaan_moore is offline Offline
Newbie Poster
 
0
  #6
28 Days Ago
Hey guys. I have this tiny bit problem stuck here. See, I have finished my RSS feed, tested it and all works perfectly, but when I remove an article from my feed it still showed in the reader. How do i get the reader to see the article is no longer part of the feed. Any ideas what's wrong?
<url snipped>
Last edited by nav33n; 28 Days Ago at 7:18 am. Reason: Keep it on the site.
Reply With Quote Quick reply to this message  
Reply

Tags
rss, validator

Message:



Similar Threads
Other Threads in the PHP Forum


Views: 925 | Replies: 5
Thread Tools Search this Thread



Tag cloud for rss, validator
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2010 DaniWeb® LLC