public function get_photo_url($photoid) {

        $cache = cache::make_from_params(cache_store::MODE_APPLICATION, 'core', 'flickrclient');

        $url = $cache->get('photourl_'.$photoid);

        if ($url === false) {
            $response = $this->call('photos.getSizes', ['photo_id' => $photoid]);
            // Sizes are returned from smallest to greatest.
            if (!empty($response->sizes->size) && is_array($response->sizes->size)) {
                while ($bestsize = array_pop($response->sizes->size)) {
                    if (isset($bestsize->source)) {
                        $url = $bestsize->source;
                        break;
                    }
                }
            }
        }

        if ($url === false) {
            throw new repository_exception('cannotdownload', 'repository');

        } else {
            $cache->set('photourl_'.$photoid, $url);
        }

        return $url;
    }