Note that there are some explanatory texts on larger screens.

plurals
  1. POusing POST JSON data with PHP cURL. Cannot get response
    primarykey
    data
    text
    <p>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.</p> <p>I am using the Coinbase API to 'generate' a button <a href="https://coinbase.com/api/doc/1.0/buttons.html" rel="nofollow">https://coinbase.com/api/doc/1.0/buttons.html</a></p> <p>I have also put the correct API in the $ch variable below as per this page</p> <p><a href="https://coinbase.com/docs/api/authentication" rel="nofollow">https://coinbase.com/docs/api/authentication</a></p> <p>It fails to fetch anything back. I have posted the correct details to get a response with some data but it fails, any ideas?</p> <p>Here is my code</p> <pre><code>&lt;?php $data = array( "button" =&gt; array( "name" =&gt; "Product Name", "price_string" =&gt; "1.23", "price_currency_iso" =&gt; "USD", "custom" =&gt; "Order 123", "description" =&gt; "Sample description", "type" =&gt; "buy_now", "style" =&gt; "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-&gt;button-&gt;type; ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload