php - 尝试通过 Guzzle 和 Laravel 连接到 Binance API
问题描述
我真的很挣扎,我不明白为什么。
基于此文档: https ://binance-docs.github.io/apidocs/spot/en/#system-status-system
我做了我的第一个请求,没有任何问题:
$data = Http::get('https://api.binance.com/sapi/v1/system/status');
if ($data) {
return response()->json($data);
}
现在当我尝试这个时:
$timeStamp = Carbon::now()->timestamp;
$query_string = 'timestamp=' . $timeStamp;
$secretKey = config('exchanges.binance.binance_secret_key');
$apiKey = config('exchanges.binance.binance_api_key');
$signature = hash_hmac('sha256', $query_string, $secretKey) . PHP_EOL;
$data = Http::withHeaders([
'X-MBX-APIKEY' => $apiKey,
])->get('https://api.binance.com/sapi/v1/capital/config/getall', [
'timestamp' => $timeStamp,
'signature' => $signature
]);
if ($data) {
return response()->json($data);
}
我不断得到这个:
cURL error 6: Could not resolve host: sapi (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for sapi/v1/capital/config/getall?xxxxxxxxxxx
知道为什么会发生这种情况,请问我真的用 Guzzle 正确地形成了我的请求吗?
谢谢你。
解决方案
推荐阅读
- python - 除了 help() 或 dir() 之外,还有什么更有效的方式来浏览模块函数、对象方法等?
- c - 程序收到信号 SIGSEGV,分段错误。#C语言#
- django - 如果对模板的更改没有反映在浏览器中,可能是什么原因?
- sql - 如何根据列长度拆分字符串并插入表中
- ios - iOS中PDF图像资产的奇怪发光效果?
- python - Python pcolormesh,每个 bin 都有单独的 alpha 值
- javascript - 在 graphql 中创建基于用户的关系的问题
- python - 在 python 中通过 weekday() 选择周末和工作日
- arrays - 如果当前值是数组,如何将新值推送到数组,或者如果它不在单个 MongoDB 查询中,如何将值设置为数组
- python - 如何在 Django 测试中发布列表