def _call(self, host, method, params, secret=None, timeout=5000):
        params['format'] = params.get('format', 'json')  # default to json

        if self.access_token:
            scheme = 'https'
            params['access_token'] = self.access_token
            host = self.ssl_host
        else:
            scheme = 'http'
            params['login'] = self.login
            params['apiKey'] = self.api_key

        if secret:
            params['signature'] = self._generateSignature(params, secret)

        # force to utf8 to fix ascii codec errors
        params = _utf8_params(params)

        request = "%(scheme)s://%(host)s/%(method)s?%(params)s" % {
            'scheme': scheme,
            'host': host,
            'method': method,
            'params': urlencode(params, doseq=1)
            }

        try:
            opener = build_opener(DontRedirect())
            opener.addheaders = [('User-agent', self.user_agent + ' urllib')]
            response = opener.open(request)
            code = response.code
            result = response.read().decode('utf-8')
            if code != 200:
                raise BitlyError(500, result)
            if not result.startswith('{'):
                raise BitlyError(500, result)
            data = json.loads(result)
            if data.get('status_code', 500) != 200:
                raise BitlyError(data.get('status_code', 500),
                                 data.get('status_txt', 'UNKNOWN_ERROR'))
            return data
        except URLError as e:
            raise BitlyError(500, str(e))
        except __HOLE__ as e:
            raise BitlyError(e.code, e.read())
        except BitlyError:
            raise
        except Exception:
            raise BitlyError(None, sys.exc_info()[1])
dataset/ETHPy150Open bitly/bitly-api-python/bitly_api/bitly_api.py/Connection._call