I
I
IgorPlays2021-04-13 16:10:19
API
IgorPlays, 2021-04-13 16:10:19

How to get AMOCRM API key?

I have a code, it sends applications from the form on the site to AmoCrm,

I need to take the key $apikey =
From amoCrm,
the old method does not work when you write AMOCRM.widgets.system.amohash in the console
What to do, how to find this key?

(Library AmoCrmAPI + composer)

<?php

require __DIR__ . '/vendor/autoload.php';

if(isset($_POST['phone'])) {

  try {
    
      $subdomain = '********'; 
      $login     = '***************';
      $apikey    = '?????????';


      $amo = new \AmoCRM\Client($subdomain, $login, $apikey);


        $lead = $amo->lead;
        $lead['name'] = $_POST['product_name'];
        $lead['responsible_user_id'] = 2462338; 
        $lead['pipeline_id'] = 1207249; 

        $lead->addCustomField(305117, [ // ID  поля в которое будт приходить заявки
        $_POST['city']], 
        ]);

        $id = $lead->apiAdd();

 
      $contact = $amo->contact;

      $contact['name'] = isset($_POST['name']) ? $_POST['name'] : 'Не указано';
      $contact['linked_leads_id'] = [(int)$id];

        $contact->addCustomField(305117, [
            [$_POST['city']],
        ]);

        $contact->addCustomField(304033, [
            [$_POST['email'], 'PRIV'],
        ]);



      $id = $contact->apiAdd();


  } catch (\AmoCRM\Exception $e) {
      printf('Error (%d): %s' . PHP_EOL, $e->getCode(), $e->getMessage());
  }

}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Valery Chmykh, 2021-04-13
@IgorPlays

From July 1, 2020, it was abandoned. To access the API, use OAuth authorization

A
Alexey Tsarapkin, 2021-04-13
@Dreamka

Read the docs for the amo API and write your own functionality, what's stopping you?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question