1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Flutter] How to use MEGA.nz for a flutter project?

Discussão em 'Mobile' iniciado por Stack, Outubro 21, 2024 às 19:13.

  1. Stack

    Stack Membro Participativo

    I'm quite new at coding and I'm using Flutter for an iOS app. The idea is to login to MEGA.nz, grab folders with videos on it with my account and use a video player library that supports .avi format videos. However, while researching online I have found that this is the api: https://g.api.mega.co.nz/cs but it's not quite working

    my code so far:

    TextEditingController emailController = TextEditingController();

    TextEditingController passwordController = TextEditingController();


    void login(String email, String password) async {
    try {
    final response = await http.post(
    Uri.parse('https://g.api.mega.co.nz/cs'),
    headers: {
    'Content-Type': 'application/json',
    },
    body: jsonEncode({
    'a': 'us',
    'user': email,
    'password': password
    }),
    );

    if (response.statusCode == 200) {
    var data = jsonDecode(response.body);
    print('Login successfully: $data');
    }else if(response.statusCode == 301
    print('Redirected to: ${response.headers['Location']}');
    } else {
    print('Failed login: ${response.statusCode} ${response.body}');
    }
    } catch (e) {
    print('Error: $e');
    }
    }


    I keep getting logged in successfully with my credentials, even when they are wrong

    Continue reading...

Compartilhe esta Página