Hi I'm trying to POST some data in an array using JSON to receive a response and output the response. So far I have followed all the parameters closely but it fails to fetch the data.
I am using the Coinbase API to 'generate' a button https://coinbase.com/api/doc/1.0/buttons.html
I have also put the correct API in the $ch variable below as per this page
https://coinbase.com/docs/api/authentication
It fails to fetch anything back. I have posted the correct details to get a response with some data but it fails, any ideas?
Here is my code
<?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?