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

荒凉一梦 提交于 2019-11-28 14:17:44

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.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!