Sugarcrm支持 产品指南 糖开发人员 糖开发人员指南10.0 食谱 网页服务 遗产API. 肥皂 PHP. 创建或更新记录
此API已被新版本成功。 建议升级到最新的API。

创建或更新记录

概述

PHP. 示例演示如何使用set_entry方法创建或更新帐户   Nusoap. 和V4_1 SOAP API。

例子

<?php

    $url = "http://{site_url}/service/v4_1/soap.php?wsdl";
    $username = "admin";
    $password = "password";

    //require NuSOAP
    require_once("./nusoap/lib/nusoap.php");

    //retrieve WSDL
    $client = new nusoap_client($url, 'wsdl');

    //display errors
    $err = $client->getError();
    if ($err)
    {
        echo '<h2>Constructor error</h2><pre>' . $err . '</pre>';
        echo '<h2>Debug</h2><pre>' . htmlspecialchars($client->getDebug(), ENT_QUOTES) . '</pre>';
        exit();
    }

    //login ---------------------------------------------------- 

    $login_parameters = array(
         'user_auth' => array(
              'user_name' => $username,
              'password' => md5($password),
              'version' => '1'
         ),
         'application_name' => 'SoapTest',
         'name_value_list' => array(
         ),
    );

    $login_result = $client->call('login', $login_parameters);

    /*
    echo '<pre>';
    print_r($login_result);
    echo '</pre>';
    */

    //get session id
    $session_id =  $login_result['id'];

    //create account ------------------------------------- 

    $set_entry_parameters = array(
         //session id
         "session" => $session_id,

         //The name of the module from which to retrieve records.
         "module_name" => "Accounts",

         //Record attributes
         "name_value_list" => array(
              //to update a record, you will nee to pass in a record id as commented below
              //array("name" => "id", "value" => "9b170af9-3080-e22b-fbc1-4fea74def88f"),
              array("name" => "name", "value" => "Test Account"),
         ),
    );

    $set_entry_result = $client->call("set_entry", $set_entry_parameters);

    echo "<pre>";
    print_r($set_entry_result);
    echo "</pre>";

?>

结果

Array
(
    [id] => 63c103dd-1f47-804c-1282-52af64b870d4
)

 

最后修改:2020-03-16 17:09:01