[HELP] Post data with php CURL
Currently I am trying to post data with cURL and PHP to populate my custom built app. However I can't seem to get anything to work. I can easily post data the same way to the CRM but not to the creator.
This is my code:
- public function serializeModelling($object) {
// Set the curl address
$this->curlAddress = 'https://creator.zoho.com/api/xml/write?';
$this->scope = 'creatorapi';
$this->token = '***';
$this->extraParameters = '';
$xmlData = '<?xml version="1.0" encoding="utf-8"?>
<ZohoCreator>
<applicationlist>
<application name="Modelleren">
<formlist>
<form name="Modelleren">
<add>
<field name="Status">
<value>new</value>
</field>
<field name="Scan">
<value>2</value>
</field>
</add>
</form>
</formlist>
</application>
</applicationlist>
</ZohoCreator>';
// Send data to push method
$this->pushToZoho($xmlData);
}
- public function pushToZoho($xmlData) {
$ch = curl_init($this->curlAddress); // Bind the address to which we post our data
echo $this->curlAddress . "<br>";
curl_setopt($ch, CURLOPT_VERBOSE, 1); //standard i/o streams
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); // Turn off the server and peer verification
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_SSL_CIPHER_LIST, 'rsa_rc4_128_sha'); // Set SSL encryption
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //Set to return data to string ($response)
curl_setopt($ch, CURLOPT_POST, 1); //Regular post
$query = $this->extraParameters;
$query .= "&authtoken={$this->token}&newFormat=1&duplicateCheck=2&scope={$this->scope}&xmlData={$xmlData}";
curl_setopt($ch, CURLOPT_POSTFIELDS, $query); // Set the request as a POST FIELD for curl.
//Execute cUrl session
$response = curl_exec($ch);
// Parse xml response into object
$this->xmlObject = simplexml_load_string($response);
echo '<pre>';
print_r($this->xmlObject);
echo '</pre>';
echo curl_error($ch);
curl_close($ch);
}
I'm not getting any responses either.. Any ideas?