关于使用SOAP连接Sugar CRM,Sugar 6.1 Community Edition的文档说明:
“有关使用情况的更多示例,请参阅/examples/SugarFullTest_Version2.php。”
此文件不在示例文件夹中。它在哪里?
如果此文件不存在,我在哪里可以找到使用SOAP连接Sugar CRM的工作示例? / examples /文件夹中的所有测试脚本都不起作用。
答案 0 :(得分:1)
无法找到该文件,因此为您做了一个示例(PHP脚本连接到sugarCRM v6 SOAP)。
<?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));
?>
对于调试和测试SoapUI非常有帮助。