So. I was able to find a very easy alternative method to gmail atom feed. I found this tutorial on google script and decided to use it…
Basically, it provides you with a URL that will return the data in the format you request, so I simply altered it to return a JSON:
/* Gmail Counter by Amit Agarwal */
/* Published on 06/17/2013 */
function doGet() {
var cache = CacheService.getPublicCache();
var counter = cache.get("gmail-counter");
// Cache the counter to stay within the Apps Script quota
if (!counter) {
counter = GmailApp.getInboxUnreadCount();
// Cache the counter value for 20 minutes
cache.put("gmail-counter", counter, 1200);
}
// You can customize the output message
counter = "{\"unread\":" + counter + "}" //<<<<<< this bit
// Output the result in plain text format
return ContentService.createTextOutput(counter)
.setMimeType(ContentService.MimeType.TEXT);
}
then created a new webhook with the URL that Google provided:
{
"event": "gmail_count",
"url": "https://script.google.com/macros/s/Xr7wodJdGwRaLW9eNGE6V-nBX_XhRr3z5d3y0G_3d7dl3e03qteT7pmz/exec",
"requestType": "GET",
"headers": null,
"query": null,
"responseTemplate": "{{unread}}",
"responseTopic": "{{PARTICLE_DEVICE_ID}}_gmail_count",
"json": null,
"auth": null,
"coreid": null,
"deviceid": null,
"mydevices": true
}
and it returns rather a rather pretty little number
Look Mom, no parsing!!!
void gotGmailFeed(const char *event, const char *data)
{
emailCount = atoi(data);
}
My word clock is happy again!