I am using the tutorial to “create a new deal” I have correctly entered the API Token,organization ID and company domain. Every time I run the script “create_deal.php” the request is sent but I do not get a response and the deal isn’t posted. Any help would be appreciated!!
I am using PHP 7.3.5, and below is the code:
<?php
// Content of create_deal.php
// Pipedrive API token
$api_token = 'xxxxx';
// Deal title and Organization ID
$deal = array(
'title' => 'New Deal Test',
'org_id' => '1'
);
$url = 'https://<company-domain>.pipedrive.com/v1/deals?api_token=' . $api_token;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $deal);
echo 'Sending request...' . PHP_EOL;
$output = curl_exec($ch);
curl_close($ch);
// Create an array from the data that is sent back from the API
// As the original content from server is in JSON format, you need to convert it to PHP array
$result = json_decode($output, true);
// Check if an ID came back, if did print it out
if (!empty($result['data']['id'])) {
echo 'Deal was added successfully!' . PHP_EOL;
}
I debugged PHP and even turned on error reporting just to be sure, no issues. I just added “curl_setopt($ch, CURLOPT_SSLVERSION, 6);” to force TLS 1.2. still getting no response.
Just asking has anyone gotten the sample code to work from the tutorial?