【发布时间】:2013-09-02 21:13:56
【问题描述】:
您好,我正在尝试使用 JSON 在数组中发布一些数据以接收响应并输出响应。到目前为止,我已密切关注所有参数,但无法获取数据。
我正在使用 Coinbase API 来“生成”一个按钮 https://coinbase.com/api/doc/1.0/buttons.html
我还根据此页面将正确的 API 放入下面的 $ch 变量中
https://coinbase.com/docs/api/authentication
它无法取回任何东西。我已经发布了正确的详细信息以获得一些数据的响应,但它失败了,有什么想法吗?
这是我的代码
<?php
$data = array(
"button" => array(
"name" => "Product Name",
"price_string" => "1.23",
"price_currency_iso" => "USD",
"custom" => "Order 123",
"description" => "Sample description",
"type" => "buy_now",
"style" => "custom_large"
)
);
$json_data = json_encode($data);
$ch = curl_init('https://coinbase.com/api/v1/buttons?api_key=MYAPIKEY');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, $json_data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($json_data))
);
$output = curl_exec($ch);
$result = json_decode($output);
echo $result->button->type;
?>
【问题讨论】:
-
curl_error的任何输出? -
啊,它给了我这个.... 卷曲错误:SSL 证书问题,验证 CA 证书是否正常。详细信息:错误:14090086:SSL 例程:SSL3_GET_SERVER_CERTIFICATE:证书验证失败。我在本地工作