Advertisement
Guest User

vtiger document create webservice

a guest
Jun 30th, 2015
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.60 KB | None | 0 0
  1. <?php
  2. $userAccessKey = 'iw1lAnsV3bAwQ9ly';
  3.  
  4. var_dump($userAccessKey);
  5.  
  6. $user ='admin';
  7. include_once('vtwsclib/Vtiger/WSClient.php');
  8. $url = 'http://cleanvt61.netinteractive.pl/';
  9. //$url = 'http://smartskills.netinteractive.pl/';
  10. //$url = 'http://pomieszczenia.1crm.pl/';
  11. //$url = 'http://pomieszczenia.niteamse.seo-linuxpl.com/';
  12. //$url = 'http://reseller.niteamse.seo-linuxpl.com/';
  13.  
  14. $client = new Vtiger_WSClient($url);
  15. $login = $client->doLogin($user, $userAccessKey);
  16. if(!$login) echo 'Login Failed';
  17. else {
  18.     $fileB64 = base64_encode(file_get_contents('test.xml'));
  19.     $moduleName = 'Documents';
  20.  
  21. // get file and file information
  22. // if you are using PHP 5.2 (!) you need to install finfo via PECL
  23. $finfo = finfo_open(FILEINFO_MIME); // return mime type ala mimetype extension.
  24. $filename = 'test.xml';
  25. $mtype = finfo_file($finfo, $filename);
  26. $model_filename=array(
  27.     'name'=>basename($filename),  // no slash nor paths in the name
  28.     'size'=>filesize($filename),
  29.     'type'=>$mtype,
  30.     'content'=>base64_encode(file_get_contents($filename))
  31. );
  32.  
  33. //fill in the details of the contacts.userId is obtained from loginResult.
  34. $contactData  = array(
  35.     //'assigned_user_id'=>$cbUserID,
  36.     'notes_title' => 'REST Test create docxxRRRxxx',
  37.     'filename'=>$model_filename,
  38.     'filetype'=>$model_filename['type'],
  39.     'filesize'=>$model_filename['size'],
  40.     'filelocationtype'=>'I',
  41.     'filedownloadcount'=> 0,
  42.     'filestatus'=>1,
  43.     'folderid' => '22x1',
  44. );
  45.  
  46. $response = $client->doCreate($moduleName, $contactData);
  47. //$dmsg.= debugmsg("Raw response (json) Create",$response);
  48.  
  49. echo "Document created with id: ".$response['id'];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement