mirror of
https://github.com/moodle/moodle.git
synced 2025-01-17 21:49:15 +01:00
MDL-76230 block_tag_flickr: Change User-agent value for API calls
This commit is contained in:
parent
40c641eceb
commit
0bfa6e4fc1
@ -22,9 +22,12 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
define('FLICKR_DEV_KEY', '4fddbdd7ff2376beec54d7f6afad425e');
|
||||
define('DEFAULT_NUMBER_OF_PHOTOS', 6);
|
||||
|
||||
require_once("{$CFG->libdir}/flickrclient.php");
|
||||
|
||||
class block_tag_flickr extends block_base {
|
||||
|
||||
function init() {
|
||||
@ -102,7 +105,11 @@ class block_tag_flickr extends block_base {
|
||||
|
||||
$response = $this->fetch_request($request);
|
||||
|
||||
$search = unserialize($response);
|
||||
$search = @unserialize($response);
|
||||
if ($search === false && $search != serialize(false)) {
|
||||
// The response didn't appear to be anything serialized, exit...
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($search['photoset']['photo'] as $p){
|
||||
$p['owner'] = $search['photoset']['owner'];
|
||||
@ -123,7 +130,11 @@ class block_tag_flickr extends block_base {
|
||||
|
||||
$response = $this->fetch_request($request);
|
||||
|
||||
$search = unserialize($response);
|
||||
$search = @unserialize($response);
|
||||
if ($search === false && $search != serialize(false)) {
|
||||
// The response didn't appear to be anything serialized, exit...
|
||||
return;
|
||||
}
|
||||
$photos = array_values($search['photos']['photo']);
|
||||
}
|
||||
|
||||
@ -147,6 +158,10 @@ class block_tag_flickr extends block_base {
|
||||
|
||||
function fetch_request($request){
|
||||
$c = new curl(array('cache' => true, 'module_cache'=> 'tag_flickr'));
|
||||
// Set custom user agent as Flickr blocks our "MoodleBot" agent string.
|
||||
$c->setopt([
|
||||
'CURLOPT_USERAGENT' => flickr_client::user_agent(),
|
||||
]);
|
||||
|
||||
$response = $c->get($request);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user