API 驱动的评级系统。该如何设置呢?
我正在尝试建立一个评级系统,与 Youtube 的“向上/向下”完全相同。 我已经问过这个问题了 (想要类似 YouTube 的喜欢/不喜欢评级系统代码吗? ) ,但无法在 API 部分获得太多帮助。尽管我在数据库部分得到了一些非常好的帮助:所以首先我有一个包含所有视频和评论的数据库,其中有一个喜欢和不喜欢的字段。然后,您可以使用 JavaScript 单击事件更新数据库,以执行 ajax 调用来增加计数。您可以使用 jQuery,代码将非常简单:
$('#up_button').click(function(){
var id = $(this).attr('thisid');
$.ajax({ type: 'POST',
url: 'AJAX/Handler/Upvote',
data: { video_id: id },
dataType: 'html',
success: function (data) { alert('success'); },
error: function (xhr, err) { alert('Error:\n\nreadyState: " + xhr.readyState + "\nstatus: " + xhr.status + "\nresponseText: " + xhr.responseText); }
});
});
然后,如果我需要知道哪些用户喜欢哪些视频,则使用两个表,一个表示喜欢,一个表示不喜欢:
TABLE likes {
user_id
video_id
}
TABLE dislikes {
user_id
video_id
}
两个表都将用户与视频相关联。 但根据我从这里收集的信息:http://code.google。 com/apis/youtube/2.0/developers_guide_protocol.html#Ratings
YouTube 使用 API 来处理所有评级。因此,我正在寻找有关如何设置 YT 所拥有的相同系统的信息和帮助。我基本上希望每个页面都有一个“喜欢/不喜欢”功能,该功能对该页面上的特定对象表示喜欢 - 就像“喜欢/不喜欢”链接到每个页面上的视频一样。最好还有一个供评论。非常非常欢迎所有帮助。从已经完成的系统的源代码(我在 Google 上搜索了很多,但从未找到类似的开源评级系统)到有关如何设置 API 支持的评级系统的帮助和信息。提前谢谢大家!
I am trying to make a rating system, exactly the same as Youtube's thumbs Up/Down.
I already asked this question
(Youtube-like like/dislike rating system code wanted?)
, but couldn't get much help on the API part. Although I got some very good help on the db part: So first I have a database with all videos and comments, that has a field for likes and dislikes. you can then update the database with JavaScript click events to perform ajax calls to increment the count. you could use jQuery and the code would be as simple as:
$('#up_button').click(function(){
var id = $(this).attr('thisid');
$.ajax({ type: 'POST',
url: 'AJAX/Handler/Upvote',
data: { video_id: id },
dataType: 'html',
success: function (data) { alert('success'); },
error: function (xhr, err) { alert('Error:\n\nreadyState: " + xhr.readyState + "\nstatus: " + xhr.status + "\nresponseText: " + xhr.responseText); }
});
});
Then, if I need to know which users liked which videos, then use two tables, one for likes and one for dislikes:
TABLE likes {
user_id
video_id
}
TABLE dislikes {
user_id
video_id
}
Both tables associate a user with a video.
But from what I gather from here: http://code.google.com/apis/youtube/2.0/developers_guide_protocol.html#Ratings
Youtube uses an API to take care of all the Ratings. So I am looking for info and help on how can I set up the same system YT has. I basically want to have a Like/Dislike function for every page, which is liked to a specific object on that page - just like the like/dislike is linked to a video on every page. Preferably also one for comments. All help is very very welcomed. From source-codes for already done systems (I searched around Google quite a bit, but never found a similar open-source rating system) to help and info on how I can set up the API-powered rating system. Thanks a bunch in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论