media_sideload_image results in http error (500)

The media_sideload_image() function is only available in the admin by default, and init runs on all page loads.

See the Codex article:

If you want to use this function outside of the context of /wp-admin/
(typically if you are writing a more advanced custom importer script)
you need to include media.php and depending includes:

require_once(ABSPATH . 'wp-admin/includes/media.php');
require_once(ABSPATH . 'wp-admin/includes/file.php');
require_once(ABSPATH . 'wp-admin/includes/image.php');