开发者

Password protected RSS feeds with account verification

We're doing a site with user generated RSS feeds which can be viewed by other users who we accounts and are verified by the source user. Is there an RSS package for php around that has password protection available that's easy to tie into a user d开发者_StackOverflowatabase?


if the RSS file name is rss.php then you can check in the php before generating XML if the user is authenticated or not !


RSS feeds can be protected using HTTP authentication. where you can use the following URL to access rss:

http://username:password@example.com/rss.php

you can allow acccess to the file by one of these methods:

  • .htaccess

  • using http authentication with PHP


You, on the database, create a unique key for all users.

id  username  rss_key
1   user_a    49f0bad29968
2   user_b    1f2414c23a7d
3   user_c    9bc46e8e52ad

Your RSS Link:

http://example.com/rss.php?Key=1f2414c23a7d

You pair the key value with the user.

<?php

$GetKey = addslashes($_GET['Key']);

//Other Rules --- Example: if(empty($GetKey)) { echo "error"; exit(); }

include("connect.php"); //Your connection file

include("session.php"); //Your session file

$Username = $User['username']; //in session file

$Match = Mysqli_Fetch_Array(Mysqli_Query($con, "SELECT u.rss_key AS 'RSSKey' WHERE user_table_name AS u WHERE u.username='".$Username."'");

if($Match['RSSKey'] !== $GetKey)
{

//Stop page
exit();

}
else{

//Your RSS Code...

}

?>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜