Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sugarcrm的RESTAPI_Rest_Spring Mvc_Sugarcrm_Sugarbean - Fatal编程技术网

Sugarcrm的RESTAPI

Sugarcrm的RESTAPI,rest,spring-mvc,sugarcrm,sugarbean,Rest,Spring Mvc,Sugarcrm,Sugarbean,Sugarcrm正在提供Restful API支持。那么我如何使用rest客户端(检查Restful web服务的浏览器插件)检查json响应呢 我正在使用SpringMVC(RESTfulAPI)开发一个web应用程序。我想使用sugarcrm作为我的crm模块。如何将两者集成 我已经阅读了sugar的文档,但是我对php编程没有任何概念。 有人能帮我吗 谢谢。运行下面的代码,如果您有任何问题,请告诉我 <?php //Put your Base url $url = 'yo

Sugarcrm正在提供Restful API支持。那么我如何使用rest客户端(检查Restful web服务的浏览器插件)检查json响应呢

我正在使用SpringMVC(RESTfulAPI)开发一个web应用程序。我想使用sugarcrm作为我的crm模块。如何将两者集成

我已经阅读了sugar的文档,但是我对php编程没有任何概念。 有人能帮我吗


谢谢。

运行下面的代码,如果您有任何问题,请告诉我

<?php 
//Put your Base url 
    $url = 'yoursugarcrm_url/service/v4_1/rest.php';
    // Open a curl session for making the call
    $curl = curl_init($url);
    // Tell curl to use HTTP POST
    curl_setopt($curl, CURLOPT_POST, true);
    // Tell curl not to return headers, but do return the response
    curl_setopt($curl, CURLOPT_HEADER, false);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    // Set the POST arguments to pass to the Sugar server
    $parameters = array(
                    'user_auth' => array(
                        'user_name'     => 'admin',
                        'password'      => md5('uDje9ceUo89nBrM'),
                        ),
    );
    $json = json_encode($parameters);
    $postArgs = array(
        'method'        => 'login',
        'input_type'    => 'JSON',
        'response_type' => 'JSON',
        'rest_data'     => $json,
    );
    curl_setopt($curl, CURLOPT_POSTFIELDS, $postArgs);
    // Make the REST call, returning the result
    $response = curl_exec($curl);
    // Convert the result from JSON format to a PHP array
    $result = json_decode($response);
    if ( !is_object($result) ) {
        die("Error handling result.\n");
    }
    if ( !isset($result->id) ) {
        die("Error: {$result->name} - {$result->description}\n.");
    }
    // Get the session id 
    $sessionId = $result->id;
    //echo  json_encode(array("sessionId"=>$sessionId));


//Your moduel parameter
//Parameter of the customer
    $fullname       = $_POST['fullname'];         
    $password       = md5($_POST['password']);
    $email_address  = $_POST['email_address'];

    // My moduel     
    $parameters = array(
        'session' => $sessionId, //Session ID   get from session.php
        'module' => 'custo_Customers', // Your PackageKey_ModuleName   
                'name_value_list' => array ( 
                      array('name' => 'fullname', 'value' => $fullname), 

                      array('name' => 'email_address', 'value' => $email_address), 
                      array('name' => 'password', 'value'      => $password), 
               ), 
        ); 

    $json       = json_encode($parameters);   // Json strgin
    $postArgs   = 'method=set_entry&input_type=JSON&response_type=JSON&rest_data=' . $json;
    curl_setopt($curl, CURLOPT_POSTFIELDS, $postArgs);

    // Make the REST call, returning the result 
    $response   = curl_exec($curl);
    // Convert the result from JSON format to a PHP array 
    $result     = json_decode($response,true); 
echo $response;
?>