vTiger SOAP bridge from WordPress and Imap server

In my last project I have to make to work together a vTiger instalation, a WordPress form and an Imap account. The best decision was to create 2 SOAP services to handle 2 requests:

Show me the code
1. Setup the webforms.php. The good thing is – you can use this SOAP service to fill ALL of your custom fields:

require_once("config.php");
require_once('include/logging.php');
require_once('include/nusoap/nusoap.php');

$NAMESPACE = 'http://www.vtiger.com/vtigercrm/';
$server = new soap_server;

// declare all of your data here. Including all of your custom fields.
$server->configureWSDL('vtigersoap');
$server->register(
	'create_newlead',
	array(	'firstname'=>'xsd:string',
                'lastname'=>'xsd:string',
                'email'=>'xsd:string',
                'phone'=>'xsd:string',              
                'lp'=>'xsd:string',
                'tr'=>'xsd:string',
                'tp'=>'xsd:string',
                'ch'=>'xsd:string',
                'assigned_user_id'=>'xsd:string',
                'cs'=>'xsd:string',
                'pt'=>'xsd:string',
                'occ'=>'xsd:string',
                'pv'=>'xsd:string',
                'la'=>'xsd:string',
                'terms'=>'xsd:string',
                'dr'=>'xsd:string',
                'ratealert' => 'xsd:string'
	     ),
	array('return'=>'xsd:string'),
	$NAMESPACE);

1.1 Write a simple function to handle the requests and to save your vTiger LEAD.

// you have to give as arguments the same fields you declared previously
function create_newlead($firstname, $lastname, $email, $phone, $lp, $tr, $tp, $ch, $assigned_user_id, $cs, $pt, $occ, $pv, $la, $terms, $dr,$ratealert)
{
             
	require_once("modules/Leads/Leads.php");
	$focus = new Leads();
	$focus->column_fields['firstname'] = $firstname;
	$focus->column_fields['lastname'] = $lastname;
	$focus->column_fields['email'] = $email;
	$focus->column_fields['phone'] = $phone;
       
//here are my custom fields
	$focus->column_fields['cf_541'] = $lp;
	$focus->column_fields['cf_542'] = $cs;
	$focus->column_fields['cf_544'] = $occ;
	$focus->column_fields['cf_545'] = $pv;
	$focus->column_fields['assigned_user_id'] = 1; //admin
	$focus->column_fields['cf_546'] = $pt;
	$focus->column_fields['cf_547'] = $terms;
	$focus->column_fields['cf_548'] = $la;
	$focus->column_fields['cf_549'] = $tr;
	$focus->column_fields['cf_550'] = $tp;
	$focus->column_fields['cf_551'] = $ch;
        $focus->column_fields['cf_552'] = $dr;
		
	$focus->save("Leads");
	
	if($focus->id != '')
		$msg = "OK";
	else
		$msg = "Error";

	return $msg;
}

2. Upload the code to ‘soap’ folder of your vTiger app.
3. Call the method from somwhere.

Important
If you have any questions or want to hire me for your WordPress project, please see the information in the right sidebar.

One response to “vTiger SOAP bridge from WordPress and Imap server”

  1. […] оказа, че мога да правя каквото си поискам чрез SOAP и то само с няколко реда на PHP. Сега всичките приложения работят ‘като пушка’, […]

Leave a Reply

Your email address will not be published. Required fields are marked *