Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $userAccessKey = 'iw1lAnsV3bAwQ9ly';
- var_dump($userAccessKey);
- $user ='admin';
- include_once('vtwsclib/Vtiger/WSClient.php');
- $url = 'http://cleanvt61.netinteractive.pl/';
- //$url = 'http://smartskills.netinteractive.pl/';
- //$url = 'http://pomieszczenia.1crm.pl/';
- //$url = 'http://pomieszczenia.niteamse.seo-linuxpl.com/';
- //$url = 'http://reseller.niteamse.seo-linuxpl.com/';
- $client = new Vtiger_WSClient($url);
- $login = $client->doLogin($user, $userAccessKey);
- if(!$login) echo 'Login Failed';
- else {
- $fileB64 = base64_encode(file_get_contents('test.xml'));
- $moduleName = 'Documents';
- // get file and file information
- // if you are using PHP 5.2 (!) you need to install finfo via PECL
- $finfo = finfo_open(FILEINFO_MIME); // return mime type ala mimetype extension.
- $filename = 'test.xml';
- $mtype = finfo_file($finfo, $filename);
- $model_filename=array(
- 'name'=>basename($filename), // no slash nor paths in the name
- 'size'=>filesize($filename),
- 'type'=>$mtype,
- 'content'=>base64_encode(file_get_contents($filename))
- );
- //fill in the details of the contacts.userId is obtained from loginResult.
- $contactData = array(
- //'assigned_user_id'=>$cbUserID,
- 'notes_title' => 'REST Test create docxxRRRxxx',
- 'filename'=>$model_filename,
- 'filetype'=>$model_filename['type'],
- 'filesize'=>$model_filename['size'],
- 'filelocationtype'=>'I',
- 'filedownloadcount'=> 0,
- 'filestatus'=>1,
- 'folderid' => '22x1',
- );
- $response = $client->doCreate($moduleName, $contactData);
- //$dmsg.= debugmsg("Raw response (json) Create",$response);
- echo "Document created with id: ".$response['id'];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement