Archive for March, 2014

I’ve been using IFTTT for a while now and its really changing the way I use online services. Just recently they added Channels for NewsBlur and Boxcar which allows for some really interesting Recipes, such as if there is a new blog post (NewsBlur) then let you know via a Push notification to your mobile device (Boxcar). This works great for the majority of my feeds but there are some that are just to busy and need to be filtered on certain keywords or RegEx matches before sending me Push notifications, as this is not currently possible (hoping it will one day) I set out to do it myself..

Thankfully NewsBlur provide a simple web based API which can be easily access with PowerShell.

First we must login to the API

$postParams = @{username='jfrmilner';password='new$blur'}
Invoke-WebRequest -Uri '' -Method Post -Body $postParams -SessionVariable newsblur

In the above lines we pass the credentials to the NewsBlur endpoint and store the session in a variable $newsblur.

$stories = @()
foreach ($i in 1..20) {
$postParams = @{page="$i";read_filter="unread"}
$newsContent = Invoke-WebRequest -Uri '' -Method Get -WebSession $newsblur -Body $postParams
$stories += $newsContent.Content | ConvertFrom-Json

In the above lines we create an array to store our stories and then collect 20 pages of results from NewsBlur that are unread. The ability to get only unread messages is one of the main reasons I collect the feeds from NewsBlur rather than directly from the sites RSS feed.

The above feed is actually for HotUKDeals. HotUKDeals allow you to customise your own RSS feeds which is nice so for this example I setup one for Gaming deals in the UK – You will also notice the feed uses a numeric ID, you can obtain this with a GET /reader/feeds call but for quick ad-hoc use the NewsBlur web portal, click your feed and you will see the number in the address bar, for example:


$myWatchList = $stories.stories | ? { $_.story_title -match "Humble|Uncharted 3" }

In the above line I use a simple RegEx to filter for stories that mention Humble or Uncharted 3.


In the above screenshot we can confirm this is working as expected; now I just need to Push this information to my phone.

Now we will just loop the results to the Send-BoxcarPush function I created my previous post.

foreach ($story in $myWatchList) {
Send-BoxcarPush -notificationTitle $story.story_title -notificationLongMessage $story.story_permalink -notificationSound cash

And to the notification sound of cash (the cash I’ll be saving) my phone lights up


#POST /reader/mark_feed_as_read
$postParams = @{feed_id=4340960}
$newsContent = Invoke-WebRequest -Uri '' -Method POST -WebSession $newsblur -Body $postParams

In the above lines we mark the feed as read to prevent getting duplicate notifications.

#POST /api/logout
#Logout the currently logged in user.
Invoke-WebRequest -Uri '' -Method POST -WebSession $newsblur

And finally we logout in the above lines.

Now all you need to do is sent this up as a scheduled task in Windows to run as frequently as you need.

As always thank you for reading and if you found this post useful please share and/or leave a comment.

Regards, jfrmilner

Not wanting to add to my already bursting email inbox and finding the need for a more immediate mobile notification of scripted events I find myself looking at and their end-user API .

The API provides an example on how to use the service with cURL so as before I will be converting this simple format to use the PowerShell Invoke-WebRequest cmdlet and wrap this into an advanced function.

•    Download the Boxcar iOS app
•    Get your Access Token and replace the value for the $user_credentials variable in the Param section of the function  – How to get the Token from the client app
•    Like all PowerShell functions you will need to run the code at least once and you can call it as many times as required for the session.

The best way to copy the code from a WordPress blog such as this one is to double click in the below window and then copy, this usually preserves the formatting.

function Send-BoxcarPush  {
A function to send Boxcar Push messages.
An example of using PowerShell to send Universal Push Notification messages. Typically the target device is a mobile running iOS ( or Andriod.
.PARAMETER notificationTitle
Message Title/Subject. 140 Character Maximum.
.PARAMETER notificationLongMessage
Message body text. 1000 Character Maximum.
.PARAMETER notificationSound
Notification Sound played on receiving device. Default is ‘bird-1’, see the Available sounds list for options -
Default is usually fine.
.PARAMETER user_credentials
Boxcar Access Token. Its recommended you change this value in the Param section of this function else it will need to be specified each time. The access token is available from the general "Settings" screen of Boxcar Client app.
Send-BoxcarPush -notificationTitle "Test Title" -notificationLongMessage "Body message text"
Author: John Milner
Blog  :
File Name: Send-BoxcarPush.ps1
Author: jfrmilner
Requires: Powershell v4 (May work on older versions but untested)
Legal: This script is provided "AS IS" with no warranties or guarantees, and confers no rights. You may use, modify, reproduce, and distribute this script file in any way provided that you agree to give the original author credit.
Version: v1.0 - 2014 March 1st - First Version
Version: v1.1 - 2014 March 2nd - Added URL Encoding
$notificationTitle = "test"
[ValidateLength(1,1000)] #Max is 4kb so 1000 is playing safe.
$notificationLongMessage = "text here"
$notificationSound = 'bird-1'
$hostURI = '' #HOST: This is the server to use to send HTTPS API calls.
$user_credentials = 'Put Your Access Token Here' #Access Token. Change this value to your own here or specify here.

Add-Type -AssemblyName System.Web

$message = Invoke-WebRequest -Uri $hostURI -Method POST -Body "user_credentials=$($user_credentials)&notification[title]=$([System.Web.HttpUtility]::UrlEncode($notificationTitle))&notification[long_message]=$([System.Web.HttpUtility]::UrlEncode($notificationLongMessage))&notification[sound]=$($notificationSound)"
if ($message.StatusCode -eq 201) {
"Message Sent:"
$message.Content | ConvertFrom-Json

catch [System.Net.WebException]
Write-Host  -ForegroundColor Red $_.Exception.Message
switch -regex ($_.Exception.Message)
"401" {Write-Host  -ForegroundColor Red "Failure: Check Access Token"}
"404" {Write-Host  -ForegroundColor Red "Failure: No associated device"}
"422" {Write-Host  -ForegroundColor Red "Failure: Unprocessable Entity - All non UTF-8 encoding are rejected"}
default {Write-Host  -ForegroundColor Red $_.Exception.Message}








Boxcar deliver a great service which is free for 200 pushes per minute and its fast, very fast.
Boxcar notifications can use 20+ different sounds which I’m starting to find quite useful, for example you can have different scripts use different sounds which I just listen out for and this saves me having to look at the phone. I’m also thinking I could use different sounds for different levels of importance.

As always thank you for reading and if you found this post useful please share and/or leave a comment.

Regards, jfrmilner