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

萝らか妹 提交于 2019-12-29 01:46:08

问题


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 example of connecting to Sugar CRM with SOAP? None of the test scripts in the /examples/ folder work.


回答1:


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.



来源:https://stackoverflow.com/questions/5396302/where-is-sugarfulltest-version2-php-sugar-crm-and-soap

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