开发者

Where is SugarFullTest_Version2.php? (Sugar CRM and SOAP)

In regards to using SOAP to connect to Sugar CRM, the documentation for Sugar 6.1 Community Edition states:

"See /examples/SugarFullTest_Version2.php for more examples on usage."

source: http://developers.sugarcrm.com/docs/OS/6.1/-docs-Developer_Guides-Sugar_Developer_Guide_6.1.0-Chapter%202%20Application%20Framework.html#9000244

This file is not in the examples folder. Where is it?

If this file does not exist, where can I find a working examp开发者_如何学Gole of connecting to Sugar CRM with SOAP? None of the test scripts in the /examples/ folder work.


Couldn't find the file either, so made an example (PHP script connecting to sugarCRM v6 SOAP) for you.

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

$myWsdl = 'http://mysite.com/soap.php?wsdl';
$myAuth = array(
    'user_name' => 'xxxx',
    'password' => MD5('xxxx'),
    'version' => '0.1'
);
$soapClient = new nusoap_client($myWsdl,true);

// Create lead
// (Can be made without login, i.e. sessionid)
$leadParams = array('user_name' => 'xxxx',
    'password' => MD5('xxxx'), 
    'first_name' => 'Test',
    'last_name' => '2',
    'email_address' => '2@'
);
$leadResult = $soapClient->call('create_lead', $leadParams);
$leadId = $leadResult;
print_r($leadResult);

// Login
$loginParams = array('user_auth' => $myAuth, 'application_name' => 'WebForm');
$loginResult = $soapClient->call('login', $loginParams);
$sessionId = $loginResult['id'];

// Modules
// (Need login, so sessionID is used)
$modulesResult = $soapClient->call('get_available_modules', array('session' => $sessionId));
print_r($modulesResult);

// Get account list
$accountParams = array('session' => $sessionId,
    'module_name' => 'Accounts',
    'query' => "accounts.name = 'Amarelo'",
    'order_by' => '',
    'deleted' => 0
);
$accountResult = $soapClient->call('get_entry_list', $accountParams);
print_r($accountResult);

// Get entry
$leadParams = array('session' => $sessionId,
    'module_name' => 'Leads',
    'id' => "$leadId"
);
$leadResult = $soapClient->call('get_entry', $leadParams);
print_r($leadResult);

// Logout
$logoutResult = $soapClient->call('logout', array('session' => $sessionId));
?>

For debugging and testing SoapUI is very helpful.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜