Some social games on Facebook let user publish a link to their feed to say, "Click here to get bonus gold coins -- limited to the first 5 people".
How can we generate such a link?
The link shouldn't be easily "generated" by any people as a cheating method.
Also, what database table(s) should be added to handle:
1) the bonus can be claimed up to 5 times
2) must be claimed by different people
(each person has a unique numeric ID on social network platform such as Facebook)
?
Update: the way I was thinking of is to get the next primary ID (an integer index) in the Prize table, and md5 it with some secret key to get a "prize code", and make sure it is not already in the "PrizeClaimed" table -- if already exist, just use the next primary ID (by adding a record and recalculate md5 until a unique one is found). This PrizeClaim table is a junction table for prize_code and user_id, so one prize can be claimed by multiple people, and one person can claim multiple prizes. If when a person clicks on the link, we add the record of the prize_code and user_id into the table -- but only if the number of records obtained by the matching the prize_code is 4 or less. If 5 already, then just report "too late -- claimed by all people". I wonder how this method is, is there any loophole, improvement, or other ways to implement it?
(for example, the Prize table is just a table for getting the ID, and it stores nothing else. Maybe we can use the current timestamp with microseconds plus a random number to do the md5, and if prize_code already exist, just repeat again. In this case we can forget about the Prize table.)
You create a table with current valid hashes, and the max count it is able to be claimed, and another table where you safe all ids that already clicked the link. By that you can check if the link still has clicks left, and that only different people have clicked it.