code: def get_json_from_remote_server(func, **kwargs):
      
      rawjson = func(**kwargs)
      if rawjson is None:
          # If the request failed we already logged in in PiwikRequest;
          # no need to get into the exception handler below.
          return {}
      try:
          data = json.loads(rawjson)
          if isinstance(data, dict) and data.get('result') == 'error':
              current_plugin.logger.error('The Piwik server responded with an error: %s', data['message'])
              return {}
          return data
      except Exception:
          current_plugin.logger.exception('Unable to load JSON from source %s', rawjson)
          return {}
docs: Safely manage calls to the remote server by encapsulating JSON creation
      from Piwik data.