Announcement

Collapse
No announcement yet.

What APIs should I call to integrate EspoCRM with Magento?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • What APIs should I call to integrate EspoCRM with Magento?

    Hi everybody,

    We have an e-commerce site running in Magento and we are selling electrical equipment. Salesforce is the current tool we use to manage customers. However, we are about to move from EspoCRM to Salesforce as Salesforce is too complicated to use.

    In order to change from EspoCRM to Salesforce, we have to make sure that the data between Magento & EspoCRM can be synchronized easily. We also plan to build an in-house integration tool between EspoCRM & Magento already. Some mapping fields are:
    - SKUs
    - Email
    - Shipping Address & 3 more fields we are discussing

    We want to build something similar to this magento salesforce integration tool we are using now. So can you tell us what APIs to develop the integration of EspoCRM & Magento?

  • #2
    Would this help? https://github.com/espocrm/documenta...lopment/api.md

    Comment


    • #3
      Tnx worldmiros

      Maybe using the Guzzle package may speed things up, here a quick and dirty script to get started with EspoCRM REST API.

      Guzzle is a PHP HTTP client that makes it easy to send HTTP requests and trivial to integrate with web services.


      PHP Code:
      <?php

      //requires Guzzle : http://docs.guzzlephp.org/en/latest/overview.html
      require 'vendor/autoload.php';

      $usr      "admin";
      $pass     "123456";
      $base_uri "http://localhost/espocrm/api/v1/";

      $b4 base64_encode($usr.":".$pass);
      echo 
      "Basic auth: $b4\n";

      use 
      GuzzleHttp\Client;

      $espo = new Client([
          
      'base_uri' => $base_uri,
          
      'auth' => [$usr$pass],
          
      'headers' => ['Espo-Authorization' => $b4]
      ]);

      // obtain token

      echo ("\nGet Token\n");
      $response $espo->request('GET''App/user');
      echo(
      "Response: ".$response->getStatusCode()." ".$response->getReasonPhrase()."\n") ;
      $body $response->getBody();
      $bodyarr =json_decode($body,true);    
      $token = ($bodyarr['token']);
      echo 
      "We got token $token\n";

      // make Espo-Authorizationstring
      $b4token base64_encode($usr.":".$token);

      // create a Client with proper defaults:
      $espoclient = new Client([
          
      'base_uri' => $base_uri,
          
      'auth' => [$usr$token],
          
      'headers' => ['Espo-Authorization' => $b4token]    
      ]);

      // GET Accounts

      echo ("\nGET Account\n");
      $response $espoclient->request('GET''Account');
      echo(
      "Response: ".$response->getStatusCode()." ".$response->getReasonPhrase()."\n")    ; // OK
      $body $response->getBody();
      $body_array =json_decode($body,true);
      echo 
      "We fetched ".$body_array['total']." records from Account\n";

      // Destroy token by posting the token to api/v1/App/action/destroyAuthToken

      echo ("\nDestroy token\n");
      $response $espoclient->request('POST''App/action/destroyAuthToken', ['json' => ['token'=>$token]]);
      echo(
      "Response: ".$response->getStatusCode()." ".$response->getReasonPhrase()."\n")    ; // OK

      ?>
      output :
      Code:
      Basic auth: YWRtaW46MTIzNDEW2  
      
      Get Token
      Response: 200 OK
      We got token d5fb21312f214b5e08c66a0db9b0fa07  
      
      GET Account
      Response: 200 OK
      We fetched 2 records from Account  
      
      Destroy token
      Response: 200 OK
      Last edited by rinorway; 05-13-2016, 11:03 AM.

      Comment

      Working...
      X