Skip to content

Instantly share code, notes, and snippets.

@mazuhl
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mazuhl/b7bb4cc8d48eb306e68c to your computer and use it in GitHub Desktop.
Save mazuhl/b7bb4cc8d48eb306e68c to your computer and use it in GitHub Desktop.
Get MODx version number from GitHub Master branch and paste into Google Spreadsheet
function myFunction() {
var response = UrlFetchApp.fetch("http://www.example.com/get-modx-latest-version.php");
SpreadsheetApp.getActiveSheet().getRange('A1').setValue(response.getContentText());
}
<?php
header('Content-Type: text/plain');
$input = file_get_contents("https://raw.githubusercontent.com/modxcms/revolution/master/_build/build.xml");
preg_match('/"modx.core.version" value="([^"]*)"/i', $input, $output_array);
if ($output_array[1] == "") {
echo "ERROR!";
} else {
echo $output_array[1];
}
?>
@mazuhl
Copy link
Author

mazuhl commented Jun 18, 2014

I couldn't find anything like an API that I could access to find out what the current version of MODx was, so I pulled this together quickly so I could include the current MODx version number in a Google Spreadsheet:

get-modx-latest-version.php

  1. Go and get the raw content of the MODx Master branch build.xml file
  2. Use a regular expression to find the version number.
  3. Output the version number (and nothing else).

Code.gs

  1. Add this to your Google Spreadsheet.
  2. Set the cell reference and the URL for your page.
  3. Set a trigger for this to run every time the page is opened.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment