• Use of rest web services in sugarCRM

    What is SugarCRM?

    Before SugarCRM, Customer Relationship Management systems were the province of large businesses that had million dollar technology budgets. The SugarCRM project was started with the belief that open source technologies had reached a point of maturation where a fast, flexible and feature-rich product could be delivered to companies who did not have money to burn. In less than two years, SugarCRM has proven that a best-in-class CRM system can be built and delivered to customers in a more economical fashion.

    The SugarCRM application furthers the high standards set by the open source community around the world. Unlike most proprietary CRM offerings, all SugarCRM applications are natively built on the pure Open Source LAMPS (also WAMPS) platform: Linux or Windows, Apache or IIS, MySQL, PHP, and SugarCRM. Our community of users actively test and contribute to the features, performance and stability of the SugarCRM application.

    Database

    MySQL – SugarCRM runs on the MySQL open source database, a simple, yet powerful, Open Source Software relational database management system which uses a subset of ANSI SQL (Structured Query Language).

    Language

    PHP – SugarCRM is written in PHP, an open source web development language.
    Why SugarCRM?

    Reasons to Choose SugarCRM

    SugarCRM is the best Customer Relationship Management tool that helps businesses automate work-flows and streamline customer-support activities.

    Explore The Different Reasons To Choose SugarCRM Over Other Open Source CRM Applications Available On The Web

    Managing customer relationships, today, is one of the most challenging tasks faced by organizations. And, this is particularly true for companies which are rapidly expanding and have to deal with thousands of clients & customers. In such a scenario, if there isn’t a CRM application, then it can be quite frustrating for businesses to manage such a large chunk of customer information and data. This is where open source software such as SugarCRM can prove to be quite handy & useful. As a business owner you might be thinking Why SugarCRM and not other crm applications. Well, there are countless reasons to choose SugarCRM, which are discussed as under.

    To begin with SugarCRM is an open source crm application, which means it comes free of cost. Plus, there are whole lot of other options available for large sized organizations. For instance, if you are small sized company, you can go for the Sugar Community Edition which can be freely downloaded from the official site. In case you are a large company that requires a dynamic crm, then there are Sugar Enterprise, Sugar Professional, Sugar Corporate and Sugar Ultimate editions to choose from. Today, SugarCRM is used by millions of business enterprises across the globe.

    Use full links:

    http://developers.sugarcrm.com/docs/OS/6.3/-docs-Developer_Guides-Sugar_Developer_Guide_6.3.0-Sugar_Developer_Guide_6.3.0.html

    Directory Structure

    SugarCRM code resides in various directories within the Sugar installation. The structure of the directories within the Sugarapplication consists of the following root level directories:

    cache: Various cache files written to the file system to minimize database accesses and store user interface templates created from metadata. Files uploaded into the application such as Note Attachments or Documents reside in this directory (refer to upload_dir parameter in the config.php file). This is an active cache directory and not all files can be deleted.

    custom: Stores upgrade-safe customizations such as custom field definitions, user interface layouts, and business logic hooks.

    data: Key system files are located here, most notably the SugarBean base class which controls the default application logic for all business objects in Sugar.

    include: Many Sugar utility functions are located here, as well as other libraries that Sugar utilizes as part of its operations. Most notable in this directory is the utils.php file that contains the most widely used utility functions.

    metadata: Contains relationship metadata for all many-to-many data relationships between the business objects.

    modules: Contains all modules in the system. Custom modules installed through the Module Loader exist here as well.

    Release || Version || REST URL || SOAP URL
    6.2.x || v4 || http://{site_url}/service/v4/rest.php || http://{site_url}/service/v4/soap.php

    6.3.x || v4 || http://{site_url}/service/v4/rest.php ||http://{site_url}/service/v4/soap.php

    6.4.x || v4_1 || http://{site_url}/service/v4_1/rest.php ||http://{site_url}/service/v4_1/soap.php

    6.5.x || v4_1 || http://{site_url}/service/v4_1/rest.php ||http://{site_url}/service/v4_1/soap.php

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    
    //Login using rest web services :
     
    <!--?php   
     
    $url = "{site_url}/service/v4_1/rest.php";
     
        $username = "username";
     
        $password = "password";
     
        //function to make cURL request
     
        function call($method, $parameters, $url)
     
        {
     
            ob_start();
     
            $curl_request = curl_init();
     
            curl_setopt($curl_request, CURLOPT_URL, $url);
     
            curl_setopt($curl_request, CURLOPT_POST, 1);
     
            curl_setopt($curl_request, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
     
            curl_setopt($curl_request, CURLOPT_HEADER, 1);
     
            curl_setopt($curl_request, CURLOPT_SSL_VERIFYPEER, 0);
     
            curl_setopt($curl_request, CURLOPT_RETURNTRANSFER, 1);
     
            curl_setopt($curl_request, CURLOPT_FOLLOWLOCATION, 0);
     
            $jsonEncodedData = json_encode($parameters);
     
            $post = array(
     
                 "method" =--> $method,
     
                 "input_type" =&gt; "JSON",
     
                 "response_type" =&gt; "JSON",
     
                 "rest_data" =&gt; $jsonEncodedData
     
            );
     
            curl_setopt($curl_request, CURLOPT_POSTFIELDS, $post);
     
            $result = curl_exec($curl_request);
     
            curl_close($curl_request);
     
            $result = explode("\r\n\r\n", $result, 2);
     
            $response = json_decode($result[1]);
     
            ob_end_flush();
     
            return $response;
     
        }
     
        //login ------------------------------------------------
     
        $login_parameters = array(
     
             "user_auth"=&gt;array(
     
                  "user_name"=&gt;$username,
     
                  "password"=&gt;md5($password),
     
                  "version"=&gt;"1"
     
             ),
     
             "application_name"=&gt;"RestTest",
     
             "name_value_list"=&gt;array(),
     
        );
     
        $login_result = call("login", $login_parameters, $url);
     
    ?&gt;
     
    //Insert using rest web services :
     
    $session_id = $login_result-&gt;id;
     
        $set_entry_parameters = array(
     
             "session" =&gt; $session_id,
     
             "module_name" =&gt; "Accounts",
     
             "name_value_list" =&gt; array(
     
                  //to update a record, you will nee to pass in a record id as commented below
     
                  //array("name" =&gt; "id", "value" =&gt; "9b170af9-3080-e22b-fbc1-4fea74def88f"),
     
                  array("name" =&gt; "name", "value" =&gt; "Test Account"),
     
             ),
     
        );
     
        $set_entry_result = call("set_entry", $set_entry_parameters, $url);
     
    //Update using rest web services :
     
    $session_id = $login_result-&gt;id;
     
        $set_entry_parameters = array(
     
             "session" =&gt; $session_id,
     
             "module_name" =&gt; "Accounts",
     
             "name_value_list" =&gt; array(
     
                  //to update a record, you will nee to pass in a record id as commented below
     
                  array("name" =&gt; "id", "value" =&gt; "9b170af9-3080-e22b-fbc1-4fea74def88f"),
     
                  array("name" =&gt; "name", "value" =&gt; "Test Account1"),
     
             ),
     
        );
     
        $set_entry_result = call("set_entry", $set_entry_parameters, $url);
     
    //Fetch record using rest web services :
     
    $session_id = $login_result-&gt;id;
     
               //get list of records -------------------------------
     
        $get_entry_list_parameters = array(
     
             'session' =&gt; $session_id,
     
             //The name of the module from which to retrieve records
     
             'module_name' =&gt; 'Accounts',
     
             //The SQL WHERE clause without the word "where".
     
             'query' =&gt; "",
     
             //The SQL ORDER BY clause without the phrase "order by".
     
             'order_by' =&gt; "",
     
             //The record offset from which to start.
     
             'offset' =&gt; '0',
     
             //Optional. A list of fields to include in the results.
     
             'select_fields' =&gt; array(
     
                  'id',
     
                  'name',
     
             ),
     
             'link_name_to_fields_array' =&gt; array(
     
             ),
     
             //The maximum number of results to return.
     
             'max_results' =&gt; '20',
     
             //To exclude deleted records
     
             'deleted' =&gt; '0',
     
             //If only records marked as favorites should be returned.
     
             'Favorites' =&gt; false,
     
        );
     
    $get_entry_list_result = call('get_entry_list', $get_entry_list_parameters, $url);

Comments on this post

Leave a Reply

  • Security Code :


    × 7 = forty nine