简体   繁体   English

有没有一种方法可以限制用户每天可以发送某种类型的请求的次数?

[英]Is there a way to limit the number of times per day a user can send a certain type of request?

What I'm doing at the moment is creating a row in a table for each Facebook request that gets sent. 目前,我正在为每个要发送的Facebook请求在表中创建一行。 Then, every time a user opens up the FB friend picker to send a request I make a call to a php file that requests information from that table and returns with a list of the FB user ids of all the people they have sent a request to in the last 24 hours. 然后,每次用户打开FB好友选择器发送请求时,我都会调用一个php文件,该文件请求该表中的信息,并返回他们向其发送请求的所有用户的FB用户ID列表。在过去的24小时内。 I do this for each type of request the user can send. 我针对用户可以发送的每种请求执行此操作。

The issue I'm having at the moment is that if the user initiates a request, sends them off to a number of people, and then immediately opens the FB friend picker again the previous request action's records have not yet all been added to our internal table. 我目前遇到的问题是,如果用户发起请求,将其发送给许多人,然后立即再次打开FB好友选择器,则先前请求操作的记录尚未全部添加到我们的内部表。 Thus, the players, if they go fast enough, can send multiple requests to the same FB friends. 因此,如果玩家走得足够快,他们可以向同一个FB朋友发送多个请求。

Is there a way, on the FB side, to limit this behavior Or is this entirely up to the developer to constrain? 在FB方面是否有办法限制这种行为?或者这完全由开发人员来约束吗? For either case, is there a recommended method by which I should achieve this behavior? 无论哪种情况,都有建议的方法来实现此行为吗? Thank you. 谢谢。

Update 更新资料

It occurred to me that our DB is keeping multiple requests from being entered on a per-user-per-24-hour period. 在我看来,我们的数据库禁止每用户每24小时输入多个请求。 What I do now is simply allow the second request to be made on the FB side and when the code attempts and fails to enter the second row into our DB it makes a FB Graph call that uses the app's auth_token to delete the request from Facebook itself. 我现在要做的只是简单地允许在FB端发出第二个请求,并且当代码尝试但未能将第二行输入到数据库中时,它会进行FB Graph调用,该调用使用应用程序的auth_token从Facebook本身删除该请求。 This means that it will show up for a moment on the receiving player's request page on Facebook but since it isn't linked with a row in the internal DB the user won't receive any reward for clicking-thru anyway. 这意味着它将在Facebook上接收玩家的请求页面上显示一会儿,但是由于它没有与内部数据库中的行链接,因此用户无论如何都不会通过点击获得任何奖励。

Thanks for the suggestions, though, everybody. 谢谢大家的建议。 @Gil Birman I went ahead and accepted your answer since it's perfectly valid, even if it's not what I ultimately used to fix the problem. @Gil Birman我继续接受了您的回答,因为它完全有效,即使这不是我最终用来解决问题的方法。 Thanks! 谢谢!

There are several ways to solve the lag problem you mentioned, one way would be to disable your send request button via javascript as soon as it is pressed. 有多种方法可以解决您提到的滞后问题,一种方法是在按下JavaScript后立即通过javascript禁用发送请求按钮。 In your javascript code, instead of immediately displaying the send request dialog via FB.UI, send a json request to your server. 在您的JavaScript代码中,与其立即通过FB.UI显示“发送请求”对话框,不如将JSON请求发送到您的服务器。 Only when the server responds should you display the fb send request dialog. 仅当服务器响应时,才显示fb发送请求对话框。 Also, the response that the server sends should include the list of friends to exclude. 另外,服务器发送的响应应包括要排除的朋友列表。 After the fb request is sent your javascript code should send one more json request to the server to indicate what rows in the database needs to be updated. 发送fb请求后,您的JavaScript代码应再向服务器发送一个json请求,以指示需要更新数据库中的哪些行。 Only when the server responds this second time should you finally re-enable your send request button. 只有当服务器第二次响应时,才应最终重新启用发送请求按钮。

However, there is no way to actually limit the # number of requests that your user can send. 但是,实际上没有办法限制用户可以发送的请求数。 That is, no matter how well you design your javascript/php code, your user could still theoretically invoke the request dialog via the Javascript console to completely bypass your attempts to secure the app. 也就是说,无论您设计javascript / php代码的程度如何,理论上,用户仍然可以通过Javascript控制台调用请求对话框,以完全绕过保护应用程序安全的尝试。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM