I'm sure many users here have heard of or currently use Reddit, the link aggregation website. If you use the website for news, to find funny jokes, to find awesome tips, etc. then you'll be happy to know that Reddit offers the ability to read data from its subreddits in the form of a JSON feed, and using Tasker we can process this feed to get the data that we want, in this case the titles of each thread. In my setup, I'm taking a random title among the top 3 posts of the day from /r/quotes.
Instructions
That's it! Pretty simple to start with. You can change the Javascriptlet to pull N number of threads into an array and mess with that if you would like. Tasker's Javascriptlet user guide is a great resource for this.
Instructions
- Variables --> Variable Set. Name %subreddit to the name of a subreddit you would like to pull from.
- Variables --> Variable Set. Name %numposts to whatever number of posts you want to pull before randomizing which one is picked.
- Net --> HTTP Get. The Server
ort you'll be grabbing is:
Code:json.reddit.com/r/%subreddit/top/?sort=top&t=day
- Code --> Javascriptlet. Here is the Javascriptlet you'll need to put under Code.
Code:var arr = JSON.parse(global("HTTPD")); var randomnumber = Math.floor((Math.random()*numposts)+1); var selftext = arr.data.children[randomnumber].data.selftext var title = arr.data.children[randomnumber].data.title
- Variables --> Variable Clear. Set Name to %HTTPD* and check Pattern Matching.
- Alert --> Say. For the text, you can say anything to preface what Tasker is about to put out. For instance, I've said it to "Your quote of the day is: %title." This should change depending on which subreddit you pull from.
That's it! Pretty simple to start with. You can change the Javascriptlet to pull N number of threads into an array and mess with that if you would like. Tasker's Javascriptlet user guide is a great resource for this.