A
A
Alexander Shapoval2017-06-02 04:09:55
PHP
Alexander Shapoval, 2017-06-02 04:09:55

Who will tell you how to use the API?

Documentation https://github.com/MinerGate/minergate-api#login
I need to authorize in PHP
All I thought of it

if( $curl = curl_init() ) {
    curl_setopt($curl, CURLOPT_URL, 'https://api.minergate.com/1.0/auth/login');
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($curl, CURLOPT_POST, true);
    curl_setopt($curl, CURLOPT_POSTFIELDS, "email=$email&password=$pass&totp=123456");
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
            'Content-Type: application/json'
        ));
    $out = curl_exec($curl);
    echo $out;
    curl_close($curl);
}

But it returns
{"code":"InvalidContent","message":"Invalid JSON: Unexpected token e in JSON at position 0"}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
DevMan, 2017-06-02
@sanek_os9

api is waiting for json, but you are sending regular data (which is what the error says).
here is a simple example.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question