How to convert developers Box.View script to PHP curl() format

I am trying to convert the following scripts supplied in this tutorial to a PHP curl() format:
http://developers.box.com/viewing-your-first-document/

Supplied script



$xxx=<<<XXX
curl https://view-api.box.com/1/documents \\
-H "Authorization: Token YOUR_API_KEY" \\
-H "Content-Type: application/json" \\
-d '{"url": "https://cloud.box.com/shared/static/4qhegqxubg8ox0uj5ys8.pdf"}' \\
-X POST
XXX;
echo $xxx;


Desired script


$json       = array ();
$jsonheader = array 
(
"Accept: application/json",
"Content-type:  application/json", 
"Authorization: TOKEN API-KEY"
);

$url = 'https://view-api.box.com/1/documents'
     . '?Authorization= TOKEN API=KEY';

curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_POST, 1 );                 // howmany parameter to post
    curl_setopt($ch, CURLOPT_POSTFIELDS, $json ); 
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true );    // don't give anything back 
    curl_setopt($ch, CURLOPT_HEADER, TRUE );            // need this to evaluate the response .. 
    curl_setopt($ch, CURLOPT_VERBOSE, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $jsonheader ); // it is httpheader not httpheader"s" 

    $output = curl_exec($ch); 

    $msg = '<br />Operation completed without any errors (only in my dreams)';
    if(curl_exec($ch) === false)
    {
      $msg = '<br />Curl error: ' . curl_error($ch);
    }
    echo $msg;  


I managed with a little help from my son who found the following:

GitHub Resource:

PDF Source File:

HTML Conversion:
http://www.johns-jokes.com/test/sample-001.pdf