Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Import contacts with picture
#1
Sad 
Hi,

In the CRM contact have picture field.
I would like to import a lot of contacts with the pictures.
Each contact have unique picture name in my disk directory.

I found this document "How to update an image field from code"
http://corebos.com/documentation/doku.php?id=en:devel:updateimagefield
Look quit complicated :-(

It there simpler way?
Reply
#2
The code you reference can't be easier. Notice that in that example it is generating a QR code before saving and that is where all the work is. In your case you want to get the image from the file system and that is where your work is. it would be something like:

PHP Code:
<?php
include_once 'vtlib/Vtiger/Module.php';
require_once 
'include/Webservices/Revise.php';
$current_user Users::getActiveAdminUser();
 
// make a query to get all the contacts you want to update
// for each contact
// get the image from the hard disk into a variable
$data file_get_contents(name of file);
// setup array for update
$model_filename=array(
    
'name'=>'whatever name you want to use' // no slash nor paths in the name
    
'size'=>strlen($data),
    
'type'=>' image/png'// change accordingly
    
'content'=>base64_encode($data)
);

$contactData  = array(
    
'attachments' => array(
        
'imagename' => $model_filename,
    ),
    
'id'=> '29x4062'// put your contact webservice ID here
);
vtws_revise($contactData$current_user);
// end loop 


let us know how it goes
Joe
TSolucio
Reply
#3
I manage to add contact + pic using the "coreBOS Web Service Developer Tool"
Now I want to run it from linux cli.
Its not clear to me from the doc what library should I include.

Some example use:

PHP Code:
include_once('vtwsclib/Vtiger/WSClient.php'); 

other:

PHP Code:
include_once 'vtlib/Vtiger/Module.php';
require_once 
'include/Webservices/Revise.php'
Reply
#4
there are two ways to use web service. from outside corebos and from inside corebos

WSClient
outside means that it is a standalone application, you have to login to the webservice endpoint and use all the methods you need. this is a mobile app, a customer portal and similar applications that connect to corebos and use it as a database.

vtlib/Vtiger/Module.php
inside corebos means that you are programming inside the framework, you don't need to login because your script lives inside the corebos application, once you are inside you can use the web service methods normally without having to login (because you already are)
Joe
TSolucio
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)