SugarCRM 5.1 has some pretty ridiculous documentation. So for those of you interested in adding a contact via the soap api, look at the code sample.

Prerequisites

1) NuSoap Libraries: http://sourceforge.net/projects/nusoap/

 

Sample Code

<?php
    // add nusoap library
    require_once('lib/nusoap.php');

    // create a soap client
    $client = new nusoap_client('http://localhost/sugar/soap.php?wsdl','wsdl','','','','');

    // Login
    $user_auth = array(
                'user_auth' => array(
                    'user_name' => 'ipshift-user',
                    'password' => md5('ipshift-password'),
                    'version' => '0.1'),
                 'application_name' => 'ipshift-crm'
        );

    $result = $client->call('login',$user_auth);

    // output the session id
    echo '<h2>Session Id:</h2>';
    print($result['id']);

    // Now Prepare a Contact
    $set_entry_params = array(
              'session' => $result['id'],
              'module_name' => 'Contacts',
              'name_value_list'=>array(
                            array('name'=>'first_name','value'=>'FirstName'),
                            array('name'=>'last_name','value'=>'LastName'),
                            array('name'=>'email1','value'=>'vmehta@ipshift.com'),
                            array('name'=>'lead_source','value'=>'Web Site'),
                            array('name'=>'phone_work', 'value'=>'1231231234'),
                            array('name'=>'account_name','value'=>'IP Shift')
                            )
                        );

    // Now Add the Contact
    $result2 = $client->call('set_entry',$set_entry_params); 

    // Show the result
    echo '<h2>Add Dump:</h2>';
    print_r($result2);
?>
  • TwitThis
  • Yahoo! Buzz
  • Digg
  • StumbleUpon
  • del.icio.us
  • Facebook
  • MySpace
  • Google
  • Blogosphere News
  • LinkedIn
  • Live
  • Reddit
  • Slashdot
  • Technorati

Previous Post: Watching Apple become Microsoft (Steve Jobs of Borg)
Next Post: Friendcast, consumer Voice Broadcast system

Leave a Reply