PHP卷曲响应

时间:2017-11-25 13:48:55

标签: php curl post

我目前正在为我的一个小项目使用API​​,它只接受POST请求,但无论我做什么,我都无法得到响应,我已经尝试回应响应,我试过返回它,我尝试使用print_r,没有任何作用。有人能告诉我我做错了吗?

<?php

$applicationPass = $_GET['appPass'];
$email = $_GET['email'];
$password = $_GET['password'];

if ($applicationPass == "abc123"){
//

$curl = curl_init();
// Set some options - we are passing in a useragent too here
curl_setopt_array($curl, array(
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_AUTOREFERER    => true, 
    CURLOPT_URL => 'http://api.minergate.com/1.0/auth/login/',
    CURLOPT_USERAGENT => 'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:10.0) Gecko/20100101 Firefox/10.0',
    CURLOPT_POST => 1,
    CURLOPT_POSTFIELDS => array(
    'email' => urlencode($_GET['email']),
    'password' => urlencode($_GET['password'])
    )
));
// Send the request & save response to $resp
$resp = curl_exec($curl);
// Close request to clear up some resources
curl_close($curl);
echo $resp;
//
}else{
    die();
}

?>

以下是我的更新代码,我的新API获得了一些不同的响应,需要永远查找。

<?php

$applicationPass = $_GET['appPass'];
$email = $_GET['email'];
$password = $_GET['password'];

if ($applicationPass == "abc123"){
//

$curl = curl_init();
// Set some options - we are passing in a useragent too here
curl_setopt_array($curl, array(
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_AUTOREFERER    => true, 
    CURLOPT_URL => 'https://minergate.com/api/2.2/auth/login',
    CURLOPT_USERAGENT => 'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:10.0) Gecko/20100101 Firefox/10.0',
    CURLOPT_CUSTOMREQUEST => 'POST',
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        'email: ' . $email,
        'password: ' . $password
    )),
    CURLOPT_POSTFIELDS => array(
    'email' => urlencode($email),
    'password' => urlencode($password)
    )
));
// Send the request & save response to $resp
$resp = curl_exec($curl);
// Close request to clear up some resources
curl_close($curl);
echo $resp;
//
}else{
    die();
}

?>

0 个答案:

没有答案