Question: I'm trying to figure out how to use the disqus-rails gem in my Rails 4 app. <https://github.com/sandric/disqus_rails>

The instructions say to include an access token in an initialiser. I can't figure out how to generate an access token. I have setup my app and channel in disqus, but can't find the token.

Where do I go to get the access token for disqus?

Answer: 
There is no *really* nice way to do this with PHP. 

You have a few options:

1. Use MySQL's newly added, built-in, scheduler: [Event Scheduler](https://dev.mysql.com/doc/refman/5.1/en/event-scheduler.html).
2. Use software from sources other than PHP or MySQL, like [cron jobs](https://stackoverflow.com/questions/21196613/run-a-mysql-query-as-a-cron-job).
3. Use a PHP library like [PHPScheduler](http://www.phpjobscheduler.co.uk/) which isn't a *true* scheduler.

---

**Option 1** is probably your best bet. It is built into MySQL, and you don't have to worry about messing with any other software that you aren't already using. 

**Option** 2 is easy to implement, but does involve using another tool other than just PHP and MySQL. You can learn how to set up cron jobs with [this post](https://askubuntu.com/questions/2368/how-do-i-set-up-a-cron-job).

**Option 3** is not recommended by me, unless you just absolutely want to use PHP to do this. But you will be limited on the customization of the scheduling. PHPScheduler isn't technically a true scheduler, and you can read why in [this post](https://stackoverflow.com/a/1269741/2542856). That post linked is older though, so it will mention that there is no scheduling available in MySQL, but since that post was made, Event Scheduler has been made.

---

To use `Event Scheduler` (**Option 1**), you should refer to [this really really good tutorial](http://www.mysqltutorial.org/mysql-triggers/working-mysql-scheduled-event/) and if you have any problems, [this documentation](https://dev.mysql.com/doc/refman/5.7/en/event-scheduler.html).

Here's a preview of how easy it is to use **Event Scheduler**:

```
CREATE EVENT nazzus_cool_event
ON SCHEDULE EVERY 1 MINUTE
STARTS CURRENT_TIMESTAMP
ENDS CURRENT_TIMESTAMP + INTERVAL 1 HOUR
DO
   INSERT INTO messages(message,created_at)
   VALUES('Nazzus cool event just happened again!',NOW());

```

This code will create an `event` called `nazzus_cool_event`, and it will occur every 1 minute(s) starting at `CURRENT_TIMESTAMP` (now), and ending an hour from now. It will insert some data into the messages table.

It's very simple but you should definitely have a quick look at this [great tutorial](http://www.mysqltutorial.org/mysql-triggers/working-mysql-scheduled-event/) so that you can see some more of its great features.
You can write a simple mysql statement that will updated your field to 0 and put it on cronjob that will run every week.

edit: 

Make sql statement that will reset your column, put it in php file and call it on cronjob, you can check it [here](https://stackoverflow.com/questions/22358382/execute-php-script-in-cron-job) , you can always use some free online solutions for cronjob like [this one](https://www.setcronjob.com/)