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:


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

// declare all of your data here. Including all of your custom fields.
	array(	'firstname'=>'xsd:string',
                'ratealert' => 'xsd:string'

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)
	$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;
	if($focus->id != '')
		$msg = "OK";
		$msg = "Error";

	return $msg;

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

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

Sending SMS messages via Twilio Rest API

I am looking at Twilio API right now for a project and I am surprised how easy is to handle voice and SMS messages. Here is an example, written by me:

ApiVersion = "2008-08-01";
	$this->AccountSid = "Axxxxxxxxxxxxxxxxxxxx"; //get your own after trial registration on Twilio.com
	$this->AuthToken = "axxxxxxxxxxxxxxxxxxxxx";
	$this->smsServer = new TwilioRestClient($this->AccountSid, $this->AuthToken);

function sendSMS($to, $from, $whattosend)

	$response = $this->smsServer->request("/$this->ApiVersion/Accounts/$this->AccountSid/SMS/Messages", 
			"POST", array(
			"To" => $to,
			"From" => $from,
			"Body" => $whattosend
			echo "Error: {$response->ErrorMessage}";
			echo "Done";


function __destruct()



$s= new Twillio_SMS;
$s->sendSMS('4155992671','4155992671','this is a test');


If you are interested in this topic, or if you have some ideas, please join me at my test repo @ Github

WRT: How to post to your WordPress using Ajax (+code)

I just finished my “share2” WRT (Web Runtime Toolkit) widget. It allows me to post quick messages to my WordpPress blog or to any blog that uses MetaWeblog API.

Here are some key parts from the script:

Ajax function that sends the requests and gets the result

function ajExec(url, param, callback, isXML) {
    var req = new XMLHttpRequest();
    req.onreadystatechange = function() {
        if (req.readyState == 4 && req.status == 200) {
            if(!isXML && req.responseText != null)
            else if(isXML && req.responseXML != null)
        } else if (req.readyState == 4 && req.status != 200) {

            var err = "Error: "+req.status;
        req.open("POST", url, true);
        req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");


Let’s click on Publish button

function sendButtonClicked(event) {
     saved_username = widget.preferenceForKey("username");
	 saved_pass = widget.preferenceForKey("pass_s");
	 saved_tags = widget.preferenceForKey("tag");
	 saved_server = widget.preferenceForKey("server");
	 pub = blogField.getText();

	ajExec(saved_server,'metaWeblog.newPostMyBlog'+saved_username+''+saved_pass+'titleThis is a postdescription'+pub+'1',showAnswer,1);

The milestone was to find correct XML structure for the query, because the examples from WordPress website and other websites are all wrong. Please see the XML and it’s structure

Download this script

You can download the application and see how works from here..

Run it

The logo:

The Settings screen:

If you want to run it into your Symbian device – rename it to share2.wgz and upload it to your device. The Symbian will do the rest. Tested on Nokia N95.