Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
app-script for taking a twilio MMS post from a 3G game camera to google drive
/* Connect your 3g game camera to google drive
* 1) buy camera: http://www.amazon.com/Covert-Special-Ops-Cellular-Camera/dp/B00806KGY6
* 2) Configure it to point to your twilio number
* 3) Deploy google app script below as a public webapp
* 4) Configure twilio to point to your app script
*/
function doGet() {
return ContentService.createTextOutput("");
}
function doPost(e) {
var drop = "camp camera";
var folder, folders = DriveApp.getFoldersByName(drop);
/* Find the folder, create if the folder does not exist */
if (folders.hasNext()) {
folder = folders.next();
} else {
folder = DriveApp.createFolder(drop);
}
/* Twilio sends the URL, download it */
/* https://www.twilio.com/docs/api/twiml/sms/twilio_request */
var blob = UrlFetchApp.fetch(e.parameters.MediaUrl0).getAs("image/jpeg");
var file = folder.createFile(blob);
return ContentService.createTextOutput("");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.