我想构建一个客户端API,服务器文档说:
DEFINITION
GET https://api.mybitx.com/api/1/balance
EXAMPLE REQUEST
$ curl -u keyid:keysecret https://api.mybitx.com/api/1/balance
这是我的代码:
<?
require_once('../config.php');
$post = [
'keyid' => $api_key,
'keysecret' => $api_secret
];
$ch = curl_init('https://api.mybitx.com/api/1/balance');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
$response = curl_exec($ch);
curl_close($ch);
var_dump($response);
?>
它给了我:
string(19) "Method Not Allowed "
但是当我跑步时:
$ curl -u *****:***** https://api.mybitx.com/api/1/balance
从SSH终端,它给了我正确的结果。我的PHP Curl代码出了什么问题?
谢谢