Tuesday, August 13, 2013

Using Canvas's API for global search and replace

So, this is a little outside my usual topics for blogging, but I always appreciate it when I find helpful code snippets online, so wanted to share this.

Today, I needed to go through 100 content pages in Instructure's Canvas LMS and make some search-and-replace type changes, but the kind that are best done using regular expressions.  I needed to rewrite image URLs, remove some links, etc.

So in case you ever need to do the same, here's the quick PHP script I threw together.  There is probably a more elegant way to do this, but I was in "get 'er done" mode :)