Laravel 上的 Coinbase API 生成以下错误日志。有人帮我解决这个问题。这个错误只发生在现场环境中,但在 xampp 中运行良好。下面是错误日志。可能是什么问题?
production.ERROR: Type error: Argument 1 passed to `Coinbase\Wallet\Exception\HttpException::exceptionClass() must be an instance of Psr\Http\Message\ResponseInterface, null given, called in /home/amunuxwq/public_html/core/vendor/coinbase/coinbase/src/Exception/HttpException.php on line 33 {"exception":"[object] (Symfony\\Component\\Debug\\Exception\\FatalThrowableError(code: 0): Type error: Argument 1 passed to Coinbase\\Wallet\\Exception\\HttpException::exceptionClass() must be an instance of Psr\\Http\\Message\\ResponseInterface, null given, called in /home/amunuxwq/public_html/core/vendor/coinbase/coinbase/src/Exception/HttpException.php on line 33 at /home/amunuxwq/public_html/core/vendor/coinbase/coinbase/src/Exception/HttpException.php:98)`
这是我在 laravel 项目中使用的代码。
<?php
namespace App;
use Coinbase\Wallet\Client;
use Coinbase\Wallet\Configuration;
use Coinbase\Wallet\Resource\Account;
use Coinbase\Wallet\Resource\Address;
class PayData {
private static $apiKey= "XXXXXXXXXXXX";
private static $apiSecret= "YYYYYYYYYYYYYYYYYYYYY";
public static function apiauth()
{
$configuration = Configuration::apiKey(self::$apiKey, self::$apiSecret);
$client = Client::create($configuration);
return $client;
}
public static function rates(){
try{
$xrate['usvalue']= PayData::apiauth()->getSpotPrice('BTC-USD')->getAmount();
$xrate['buyvalue']=PayData::apiauth()->getBuyPrice('BTC-USD')->getAmount();
$xrate['sellvalue']=PayData::apiauth()->getSellPrice('BTC-USD')->getAmount();
return $xrate;
}
catch (Exception $e){
$msg =$e->getMessage();
return $msg;
}
}
Public static function myaddress($name){
try{
$account =PayData::apiauth()->getPrimaryAccount();
$address= new Address ([
'name'=>$name
]);
$add = PayData::apiauth()->createAccountAddress($account,$address);
//$addressId=PayData::apiauth()->getAccountAddresses($account);
//$addressd = $addressId->getfirstID();
//$address = PayData::apiauth()->getAccountAddress($account,$addressd);
//echo $address->getAddress();
return $add->getAddress();
}
catch (Exception $e){
report ($e);
return false;
}
}
}
最佳答案
您必须在 etc
文件夹中更新您的 coinbase 证书 (ca-coinbase.crt
)。
它会起作用:)
关于php - 实时服务器上的 Laravel Coinbase API Http 异常错误但适用于 Xampp,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60969914/
相关文章:
python - 计数没有。使用 dask 的大型 Parquet 文件中的行数没有内存错误
asp.net-core - 为什么 controllerbase.challenge 返回 200
emacs - 如何将ctags格式文件转换为etags格式文件?
laravel - 使用 Nuxt 前端实现 Laravel 7 Passport 身份验证
unit-testing - 在 Racket 中使用模拟对象进行猴子修补
javascript - jsdoc如何描述返回SAME CLASS变量的静态类方法
javascript - mxgraph 避免边缘重叠节点或其他边缘