Uploading files to Zoho API with PHP Curl -
i trying attach file zoho crm account page using zohocrm api , not having success. using curl , php5.3 (no curl_file_create, using hand rolled version).
in log following report
curl::post url: https://crm.zoho.com/crm/private/json/accounts/uploadfile?authtoken=my_token&scope=crmapi params: array( [content] => @/tmp/b2d-jbjvmy;filename=b2d-jbjvmy;type=application/pdf [id] => my_account_id )
i no response zohocrm , file not attached target account record. doing wrong?
here's excerpts code may or hinder: ... other methods zohoapi class such getsearchrecords appear working fine...
class curl { ... protected static function post($url, $params) { $ch = curl_init(); curl_setopt($ch, curlopt_url, $url); curl_setopt($ch, curlopt_header,0); curl_setopt($ch, curlopt_returntransfer, true); curl_setopt($ch, curlopt_ssl_verifypeer, false); curl_setopt($ch, curlopt_post, true); curl_setopt($ch, curlopt_postfields, $params); $data = curl_exec($ch); curl_close($ch); return $data; } ... } class zohoapi extends curl { .... protected function apipost($url, $params) { $url .= "?authtoken={$this->token}&scope={$this->scope}"; $apiparams = empty($params) ? '' : $params; return $this->post($url, $apiparams); } ... public function uploadfile($module='accounts', $zohoid = '', $file ) { $url = "{$this->apiurl}/{$this->mode}/{$module}/uploadfile"; $params = array( 'content' => curl_file_create($file, 'application/pdf' , basename( $file, '.pdf')), 'id' => $zohoid ); return $this->apipost($url, $params); } ... }
when trying upload file, check have permission :-(
turns out file trying upload not read process.
Comments
Post a Comment