php - 卷曲试图获取非对象的属性
问题描述
用 Coinbase 付款 a 写道:`
$amount = isset($_POST['AMOUNT']) ? filter_input(INPUT_POST, 'AMOUNT', FILTER_SANITIZE_NUMBER_FLOAT) : 0.0;
$memo = isset($_POST['MEMO']) ? filter_input(INPUT_POST, 'MEMO', FILTER_SANITIZE_STRING) : '';
$cust_name = isset($_POST['sName']) ? filter_input(INPUT_POST, 'sName', FILTER_SANITIZE_STRING) : '';
$cust_id = isset($_POST['sID']) ? filter_input(INPUT_POST, 'sID', FILTER_SANITIZE_NUMBER_INT) : 0;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.commerce.coinbase.com/charges/");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$post = array(
"name" => "Payement to CSI",
"description" => $memo,
"local_price" => array(
'amount' => $amount,
'currency' => 'USD'
),
"pricing_type" => "fixed_price",
"metadata" => array(
'customer_id' => $cust_id,
'customer_name' => $cust_name
)
);
$post = json_encode($post);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_POST, 1);
$headers = array();
$headers[] = "Content-Type: application/json";
$headers[] = "X-Cc-Api-Key: 81xxxxxxxx-41a4-xxxxx-f4axxxxxxxx";
$headers[] = "X-Cc-Version: 2018-03-22";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
curl_close ($ch);
$response = json_decode($result);
return $response->data->hosted_url;`
但我得到一个错误:
试图在第 64 行的 C:\Users\kjkj\Documents\ProjetCrypt\coinBasePayment.php 中获取非对象的属性
我做了一个var_dump($response)
,它返回NULL,但为什么呢?我确定代码没问题。请有任何建议
解决方案
推荐阅读
- javascript - 如何在 vue.js 中显示缓冲区
- python - 关系实例没有附加成员 pylint :VS Code
- opencart - 从添加可选值价格中删除原始价格
- lightningchart - 更改 LightningChart 标题大小和颜色
- android - Android libgdx 无法识别 Facebook ShareDialog (Facebook SDK)
- node.js - MongoDB $pull 查询无法正常工作
- c# - 如何在不从外部更改实体的情况下对实体执行数学运算?
- sql-server - 为什么在引发除以零异常后执行插入语句
- ruby-on-rails - 使用 rails 6 active storage 不显示 PDF
- apollo-server - 是否可以为 Apollo Server 附带的 GraphQL Playground 定义 HTTP 标头?