def vk_api(backend, method, data):
 data['v'] = backend.setting('API_VERSION', '3.0')
 if ('access_token' not in data):
  (key, secret) = backend.get_key_and_secret()
  if ('api_id' not in data):
   data['api_id'] = key
  data['method'] = method
  data['format'] = 'json'
  url = 'http://api.vk.com/api.php'
  param_list = sorted(list((((item + '=') + data[item]) for item in data)))
  data['sig'] = md5((''.join(param_list) + secret).encode('utf-8')).hexdigest()
 else:
  url = ('https://api.vk.com/method/' + method)
 try:
  return backend.get_json(url, params=data)
 except (TypeError, KeyError, IOError, ValueError, IndexError):
  return None

def vk_api ( backend , method , data ) : data [ 'v' ] = backend . setting ( 'API_VERSION' , '3.0' ) if ( 'access_token' not in data ) : ( key , secret ) = backend . get_key_and_secret ( ) if ( 'api_id' not in data ) : data [ 'api_id' ] = key data [ 'method' ] = method data [ 'format' ] = 'json' url = 'http://api.vk.com/api.php' param_list = sorted ( list ( ( ( ( item + '=' ) + data [ item ] ) for item in data ) ) ) data [ 'sig' ] = md5 ( ( '' . join ( param_list ) + secret ) . encode ( 'utf-8' ) ) . hexdigest ( ) else : url = ( 'https://api.vk.com/method/' + method ) try : return backend . get_json ( url , params = data ) except ( TypeError , KeyError , IOError , ValueError , IndexError ) : return None
calls vk .