To convert the cURL syntax to PHP syntax, you can use the curl_setopt function to set the options for the cURL request. Here's an example of how you can achieve this in PHP:
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, '{baseUrl}/signature_requests/{signatureRequestId}/documents');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, [
'file' => new CURLFile('/path/to/the/document/test.pdf'),
'nature' => 'signable_document'
]);
curl_setopt($curl, CURLOPT_HTTPHEADER, [
'Authorization: Bearer {apiKey}'
]);
$response = curl_exec($curl);
curl_close($curl);
return $response;
In this example, we're using the curl_init function to initialize a new cURL session. We then use the curl_setopt function to set the options for the cURL request.
We set the URL for the request using CURLOPT_URL, and set CURLOPT_RETURNTRANSFER to true to return the response as a string. We set CURLOPT_POST to true to indicate that we're making a POST request, and use CURLOPT_POSTFIELDS to set the data to be sent in the request.
We set the file parameter to a new CURLFile object, which takes the path to the file as its argument. We set the nature parameter to 'signable_document'.
Finally, we set the Authorization header using CURLOPT_HTTPHEADER, and pass in an array with the header value.
Once we've set all the options, we execute the cURL request using curl_exec, and close the cURL session using curl_close. The response from the request is returned as a string.