From 2972e660082ebe1f2d99d2b74b62349067b44f1c Mon Sep 17 00:00:00 2001 From: Paul Holden Date: Tue, 26 Apr 2022 14:10:18 +0100 Subject: [PATCH] MDL-74567 repository_flickr: replace user-agent value for API calls. Flickr doesn't like user agent that looks like a bot. Effectively the same reasoning/fix as b8ee31a0. --- lib/flickrlib.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/flickrlib.php b/lib/flickrlib.php index c48c7f795c3..4b38b5dbc40 100644 --- a/lib/flickrlib.php +++ b/lib/flickrlib.php @@ -78,7 +78,13 @@ class phpFlickr { //Find the PHP version and store it for future reference $this->php_version = explode("-", phpversion()); $this->php_version = explode(".", $this->php_version[0]); + + // Initialize curl helper, set custom user agent as Flickr blocks our "MoodleBot" agent string. $this->curl = new curl(array('cache'=>true, 'module_cache'=>'repository')); + $version = moodle_major_version(); + $this->curl->setopt([ + 'CURLOPT_USERAGENT' => "MoodleSite/$version (+{$CFG->wwwroot})" + ]); } function request ($command, $args = array())