943,102 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 1965
  • PHP RSS
Nov 21st, 2009
0

how to validate a rss feed address

Expand Post »
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..
PHP Syntax (Toggle Plain Text)
  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..
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
ym_chaitu is offline Offline
18 posts
since Jun 2009
Nov 21st, 2009
0
Re: how to validate a rss feed address
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?

PHP Syntax (Toggle Plain Text)
  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 blocblue; Nov 21st, 2009 at 3:50 pm.
Reputation Points: 101
Solved Threads: 74
Posting Pro in Training
blocblue is offline Offline
417 posts
since Jan 2008
Nov 22nd, 2009
0
Re: how to validate a rss feed address
do an iframe folks!
Reputation Points: 15
Solved Threads: 7
Posting Pro in Training
SKANK!!!!! is offline Offline
428 posts
since Apr 2009
Nov 22nd, 2009
0
Re: how to validate a rss feed address
Oh and by the way, if you want to do redirects within PHP, try using the Header method instead. E.g.

PHP Syntax (Toggle Plain Text)
  1. header('Location: target.html');

R.
Reputation Points: 101
Solved Threads: 74
Posting Pro in Training
blocblue is offline Offline
417 posts
since Jan 2008
Nov 23rd, 2009
0
Re: how to validate a rss feed address
i dont have curl installed in my php..Is there any way to do it without using curl.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
ym_chaitu is offline Offline
18 posts
since Jun 2009
Feb 22nd, 2010
0
Re: how to validate a rss feed address
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; Feb 22nd, 2010 at 8:18 am. Reason: Keep it on the site.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Canaan_moore is offline Offline
2 posts
since Feb 2010

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: Reading text file character by character
Next Thread in PHP Forum Timeline: onclick show images in table from form





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC