public function call($function, array $params = [], $method = 'GET') {

        if (strpos($function, 'flickr.') !== 0) {
            $function = 'flickr.'.$function;
        }

        $params['method'] = $function;
        $params['format'] = 'json';
        $params['nojsoncallback'] = 1;

        $rawresponse = $this->request($method, self::REST_ROOT, $params);
        $response = json_decode($rawresponse);

        if (!is_object($response) || !isset($response->stat)) {
            throw new moodle_exception('flickr_api_call_failed', 'core_error', '', $rawresponse);
        }

        if ($response->stat === 'ok') {
            return $response;

        } else if ($response->stat === 'fail' && $response->code == 98) {
            // Authentication failure, give the caller a chance to re-authenticate.
            return false;

        } else {
            throw new moodle_exception('flickr_api_call_failed', 'core_error', '', $response);
        }

        return $response;
    }
public function call($function, array $params = [], $method = 'GET') {

        if (strpos($function, 'flickr.') !== 0) {
            $function = 'flickr.'.$function;
        }

        $params['method'] = $function;
        $params['format'] = 'json';
        $params['nojsoncallback'] = 1;

        $rawresponse = $this->request($method, self::REST_ROOT, $params);
        $response = json_decode($rawresponse);

        if (!is_object($response) || !isset($response->stat)) {
            throw new moodle_exception('flickr_api_call_failed', 'core_error', '', $rawresponse);
        }

        if ($response->stat === 'ok') {
            return $response;

        } else if ($response->stat === 'fail' && $response->code == 98) {
            // Authentication failure, give the caller a chance to re-authenticate.
            return false;

        } else {
            throw new moodle_exception('flickr_api_call_failed', 'core_error', '', $response);
        }

        return $response;
    }
public function call ( $ function , array $ params = [ ] , $ method = 'GET' ) { if ( strpos ( $ function , 'flickr.' ) !== 0 ) { $ function = 'flickr.' . $ function ; } $ params [ 'method' ] = $ function ; $ params [ 'format' ] = 'json' ; $ params [ 'nojsoncallback' ] = 1 ; $ rawresponse = $ this -> request ( $ method , self :: REST_ROOT , $ params ) ; $ response = json_decode ( $ rawresponse ) ; if ( ! is_object ( $ response ) || ! isset ( $ response -> stat ) ) { throw new moodle_exception ( 'flickr_api_call_failed' , 'core_error' , '' , $ rawresponse ) ; } if ( $ response -> stat === 'ok' ) { return $ response ; } else if ( $ response -> stat === 'fail' && $ response -> code == 98 ) { // Authentication failure, give the caller a chance to re-authenticate. return false ; } else { throw new moodle_exception ( 'flickr_api_call_failed' , 'core_error' , '' , $ response ) ; } return $ response ; }
Call a Flickr API method.

@param string $function API function name like 'flickr.photos.getSizes' or just 'photos.getSizes'
@param array $params Additional API call arguments.
@param string $method HTTP method to use (GET or POST).
@return object|bool Response as returned by the Flickr or false on invalid authentication
Call a Flickr API method .