From db898e5f77fc87e80777e4499bae94525b8c65b1 Mon Sep 17 00:00:00 2001 From: mesilov Date: Tue, 27 Aug 2024 01:34:56 +0600 Subject: [PATCH] Remove local application files and update examples Deleted outdated local application files including .env, activity-handler.php, and robot-handler.php. Updated README with detailed instructions and examples on working with webhooks and local applications. Added a new composer.json for dependency management in the local-application directory. Signed-off-by: mesilov --- README.md | 123 ++++++++- examples/application/local/.env | 8 - .../application/local/activity-handler.php | 156 ----------- examples/application/local/index.php | 254 ------------------ examples/application/local/robot-handler.php | 87 ------ examples/local-application/composer.json | 20 ++ examples/local-application/index.php | 36 +++ .../local => local-application}/install.php | 5 +- 8 files changed, 173 insertions(+), 516 deletions(-) delete mode 100644 examples/application/local/.env delete mode 100644 examples/application/local/activity-handler.php delete mode 100644 examples/application/local/index.php delete mode 100644 examples/application/local/robot-handler.php create mode 100644 examples/local-application/composer.json create mode 100644 examples/local-application/index.php rename examples/{application/local => local-application}/install.php (53%) diff --git a/README.md b/README.md index bbe60abe..b51d9dc2 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,8 @@ API - level features Performance improvements πŸš€ -- [x] Batch queries implemented with [PHP Generators](https://www.php.net/manual/en/language.generators.overview.php) – constant low memory and low CPI usage: +- [x] Batch queries implemented with [PHP Generators](https://www.php.net/manual/en/language.generators.overview.php) – + constant low memory and low CPI usage: - [x] batch read data from bitrix24 - [x] batch write data to bitrix24 - [x] read without count flag @@ -77,6 +78,7 @@ Performance improvements πŸš€ output: b24 response dto process: b24 entities, operate with immutable objects ``` + ## Documentation - [Bitrix24 API documentation - English](https://training.bitrix24.com/rest_help/) @@ -99,12 +101,20 @@ Add `"mesilov/bitrix24-php-sdk": "2.x"` to `composer.json` of your application. ## Examples ### Work with webhook + 1. Go to `/examples/webhook` folder 2. Open console and install dependencies + ```shell composer install ``` -3. Open example file and insert webhook url into `$webhookUrl` + +3. Open Bitrix24 portal: Developer resources β†’ Other β†’ Inbound webhook +4. Open example file and insert webhook url into `$webhookUrl` + +
+ see example.php file + ```php declare(strict_types=1); @@ -132,12 +142,103 @@ var_dump($b24Service->getMainScope()->main()->getCurrentUserProfile()->getUserPr // get deals list and address to first element var_dump($b24Service->getCRMScope()->lead()->list([], [], ['ID', 'TITLE'])->getLeads()[0]->TITLE); ``` -4. call php file in cli + +
+ +5. Call php file in shell + ```shell php -f example.php +``` + +### Work with local application + +1. Go to `/examples/local-application` folder +2. Open console and install dependencies + +```shell +composer install +``` + +3. Start local development server + +```shell +sudo php -S 127.0.0.1:80 +``` + +4. Expose local server to public via [ngrok](https://ngrok.com/) and remember temporally public url – + `https://****.ngrok-free.app` + +```shell +ngrok http 127.0.0.1 +``` + +5. Check public url from ngrok and see `x-powered-by` header with **200** status-code. + +```shell +curl https://****.ngrok-free.app -I +HTTP/2 200 +content-type: text/html; charset=UTF-8 +date: Mon, 26 Aug 2024 19:09:24 GMT +host: ****.ngrok-free.app +x-powered-by: PHP/8.3.8 +``` + +6. Open Bitrix24 portal: Developer resources β†’ Other β†’ Local application and create new local application: + - `type`: server + - `handler path`: `https://****.ngrok-free.app/index.php` + - `Initial installation path`: `https://****.ngrok-free.app/install.php` + - `Menu item text`: `Test local app` + - `scope`: `crm` +7. Save application parameters in `index.php` file: + - `Application ID (client_id)` β€” `BITRIX24_PHP_SDK_APPLICATION_CLIENT_ID` + - `Application key (client_secret)` β€” `BITRIX24_PHP_SDK_APPLICATION_CLIENT_SECRET` + - `Assing permitions (scope)` β€” `BITRIX24_PHP_SDK_APPLICATION_SCOPE` +
+ see index.php file + +```php +declare(strict_types=1); + +use Bitrix24\SDK\Core\Credentials\AuthToken; +use Bitrix24\SDK\Core\Credentials\ApplicationProfile; +use Bitrix24\SDK\Services\ServiceBuilderFactory; +use Monolog\Handler\StreamHandler; +use Monolog\Logger; +use Monolog\Processor\MemoryUsageProcessor; +use Symfony\Component\EventDispatcher\EventDispatcher; +use Symfony\Component\HttpFoundation\Request; + +require_once 'vendor/autoload.php'; +?> +
+    Application is worked, auth tokens from bitrix24:
+    
+
+pushHandler(new StreamHandler('bitrix24-php-sdk.log')); +$log->pushProcessor(new MemoryUsageProcessor(true, true)); + +$b24ServiceBuilderFactory = new ServiceBuilderFactory(new EventDispatcher(), $log); +$appProfile = ApplicationProfile::initFromArray([ + 'BITRIX24_PHP_SDK_APPLICATION_CLIENT_ID' => 'INSERT_HERE_YOUR_DATA', + 'BITRIX24_PHP_SDK_APPLICATION_CLIENT_SECRET' => 'INSERT_HERE_YOUR_DATA', + 'BITRIX24_PHP_SDK_APPLICATION_SCOPE' => 'INSERT_HERE_YOUR_DATA' +]); +$b24Service = $b24ServiceBuilderFactory->initFromRequest($appProfile, AuthToken::initFromPlacementRequest($request), $request->get('DOMAIN')); + +var_dump($b24Service->getMainScope()->main()->getCurrentUserProfile()->getUserProfile()); +// get deals list and address to first element +var_dump($b24Service->getCRMScope()->lead()->list([], [], ['ID', 'TITLE'])->getLeads()[0]->TITLE); ``` +
+8. Save local application in Bitrix24 tab and press Β«OPEN APPLICATIONΒ» button. + + ### Create application for Bitrix24 marketplace if you want to create application you can use production-ready contracts in namespace @@ -146,16 +247,22 @@ if you want to create application you can use production-ready contracts in name - `Bitrix24Accounts` β€” Store auth tokens and provides [methods](src/Application/Contracts/Bitrix24Accounts/Docs/Bitrix24Accounts.md) for work with Bitrix24 account. -- `ApplicationInstallations` β€” Store information about [application installation](src/Application/Contracts/ApplicationInstallations/Docs/ApplicationInstallations.md), linked with Bitrix24 Account with auth +- `ApplicationInstallations` β€” Store information + about [application installation](src/Application/Contracts/ApplicationInstallations/Docs/ApplicationInstallations.md), + linked with Bitrix24 Account with auth tokens. Optional can store links to: - Client contact person: client person who responsible for application usage - Bitrix24 Partner contact person: partner contact person who supports client and configure application - Bitrix24 Partner: partner who supports client portal -- `ContactPersons` – Store information [about person](src/Application/Contracts/ContactPersons/Docs/ContactPersons.md) who installed application. -- `Bitrix24Partners` – Store information about [Bitrix24 Partner](src/Application/Contracts/Bitrix24Partners/Docs/Bitrix24Partners.md) who supports client portal and install or configure application. +- `ContactPersons` – Store information [about person](src/Application/Contracts/ContactPersons/Docs/ContactPersons.md) + who installed application. +- `Bitrix24Partners` – Store information + about [Bitrix24 Partner](src/Application/Contracts/Bitrix24Partners/Docs/Bitrix24Partners.md) who supports client + portal and install or configure application. Steps: -1. Create own entity of this bounded contexts. + +1. Create own entity of this bounded contexts. 2. Implement all methods in contract interfaces. 3. Test own implementation behavior with contract-tests `tests/Unit/Application/Contracts/*` – examples. @@ -171,6 +278,7 @@ Call in command line ```shell make lint-phpstan ``` + ### PHP Static Analysis Tool – rector Call in command line for validate @@ -178,6 +286,7 @@ Call in command line for validate ```shell make lint-rector ``` + Call in command line for fix codebase ```shell diff --git a/examples/application/local/.env b/examples/application/local/.env deleted file mode 100644 index ef1ad926..00000000 --- a/examples/application/local/.env +++ /dev/null @@ -1,8 +0,0 @@ -# monolog -LOGS_LEVEL=100 -LOGS_FILE_NAME=bitrix24-php-sdk.log - -# local application secret parameters -BITRIX24_PHP_SDK_APPLICATION_CLIENT_ID= -BITRIX24_PHP_SDK_APPLICATION_CLIENT_SECRET= -BITRIX24_PHP_SDK_APPLICATION_SCOPE= \ No newline at end of file diff --git a/examples/application/local/activity-handler.php b/examples/application/local/activity-handler.php deleted file mode 100644 index fbb6af41..00000000 --- a/examples/application/local/activity-handler.php +++ /dev/null @@ -1,156 +0,0 @@ - -
-    ΠŸΡ€ΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠ΅ Ρ€Π°Π±ΠΎΡ‚Π°Π΅Ρ‚, ΠΏΠΎΠ»ΡƒΡ‡ΠΈΠ»ΠΈ Ρ‚ΠΎΠΊΠ΅Π½Ρ‹ ΠΎΡ‚ Битрикс24:
-    
-
-bootEnv('.env'); - -if ($_SERVER['APP_DEBUG']) { - umask(0000); - - if (class_exists( - Debug::class - )) { - Debug::enable(); - } -} - - -try { - $log = new Logger('bitrix24-php-sdk-cli'); - $log->pushHandler(new StreamHandler($_ENV['LOGS_FILE_NAME'], (int)$_ENV['LOGS_LEVEL'])); - $log->pushProcessor(new MemoryUsageProcessor(true, true)); - - $req = Request::createFromGlobals(); - $log->debug('incoming request', [ - 'payload' => $req->request->all() - ]); - - $workflowReq = IncomingRobotRequest::initFromRequest($req); - - print_r($workflowReq); - - $b24ServiceFactory = new ServiceBuilderFactory(new EventDispatcher(), $log); - $appProfile = ApplicationProfile::initFromArray($_ENV); - - //AccessToken::initFromWorkflowRequest($req), - $b24Service = $b24ServiceFactory->initFromRequest( - $appProfile, - $workflowReq->auth->accessToken, - $workflowReq->auth->domain - ); - - $returnProp = [ - 'result_sum' => 5555 - ]; - - print('PROP' . PHP_EOL); - print_r($workflowReq->properties); - print_r($b24Service->getMainScope()->main()->getCurrentUserProfile()->getUserProfile()); - - $b24Service->getBizProcScope()->activity()->log( - $workflowReq->eventToken, - 'hello from activity handler' - ); - - $res = $b24Service->getBizProcScope()->event()->send( - $workflowReq->eventToken, - $returnProp, - sprintf('debug result %s', print_r($returnProp, true)) - ); - $log->debug('ffffffff', [ - 'res' => $res->isSuccess() - ]); - -} catch (Throwable $exception) { - - $log->error(sprintf('error: %s', $exception->getMessage()), [ - 'trace' => $exception->getTraceAsString() - ]); - - print('ERRRRRRRRRORRRR!!!!'); - print($exception->getMessage() . PHP_EOL); - print_r($exception->getTraceAsString()); - -} - - -// Array -// ( -// [workflow_id] => 664fa13bbbb410.99176768 -// [code] => test_activity -// [document_id] => Array -// ( -// [0] => crm -// [1] => CCrmDocumentContact -// [2] => CONTACT_109286 -// ) -// -// [document_type] => Array -// ( -// [0] => crm -// [1] => CCrmDocumentContact -// [2] => CONTACT -// ) -// -// [event_token] => 664fa13bbbb410.99176768|A40364_79843_85254_57332|MS1ekdI0CvXi8ycL8qNIn96hak8JEndG.54020ce210345fb6eb12a79d75316d9430b42ccd9c1d82ab1a3bf8b064ec50e9 -// [properties] => Array -// ( -// [comment] => дСфолтная строка - Π·Π½Π°Ρ‡Π΅Π½ΠΈΠ΅ -// [amount] => 333 -// ) -// -// [use_subscription] => Y -// [timeout_duration] => 660 -// [ts] => 1716494651 - -// [auth] => Array -// ( - -// access token -// [access_token] => 4baf4f66006e13540058f18a000000100000009b41bce7ec85f07c3646c07e6d629e7c -// [refresh_token] => 3b2e7766006e13540058f18a000000100000003b31a96730e79dc7561c1d7d0b33933f -// [expires] => 1716498251 - -// endpoints -// [server_endpoint] => https://oauth.bitrix.info/rest/ -// [client_endpoint] => https://bitrix24-php-sdk-playground.bitrix24.ru/rest/ - -// scope -// [scope] => crm,bizproc,appform,baas,placement,user_brief,call,telephony - -// application status -// [status] => L - - -// [application_token] => f9ac5db5ad4adbdee13eb034207d8fbd -// [expires_in] => 3600 -// [domain] => bitrix24-php-sdk-playground.bitrix24.ru -// [member_id] => 010b6886ebc205e43ae65000ee00addb -// [user_id] => 16 -// ) -//) diff --git a/examples/application/local/index.php b/examples/application/local/index.php deleted file mode 100644 index 6a6e55d3..00000000 --- a/examples/application/local/index.php +++ /dev/null @@ -1,254 +0,0 @@ - -
-    ΠŸΡ€ΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠ΅ Ρ€Π°Π±ΠΎΡ‚Π°Π΅Ρ‚, ΠΏΠΎΠ»ΡƒΡ‡ΠΈΠ»ΠΈ Ρ‚ΠΎΠΊΠ΅Π½Ρ‹ ΠΎΡ‚ Битрикс24:
-    
-
-bootEnv('.env'); - -if ($_SERVER['APP_DEBUG']) { - umask(0000); - - if (class_exists( - Debug::class - )) { - Debug::enable(); - } -} - -$request = Request::createFromGlobals(); - - -$log = new Logger('bitrix24-php-sdk-cli'); -$log->pushHandler(new StreamHandler($_ENV['LOGS_FILE_NAME'], (int)$_ENV['LOGS_LEVEL'])); -$log->pushProcessor(new MemoryUsageProcessor(true, true)); - -$b24ServiceFactory = new ServiceBuilderFactory(new EventDispatcher(), $log); -$appProfile = ApplicationProfile::initFromArray($_ENV); -$b24Service = $b24ServiceFactory->initFromRequest($appProfile, AuthToken::initFromPlacementRequest($request), $_REQUEST['DOMAIN']); - - -var_dump('Hello world'); - -var_dump(Bitrix24\SDK\Core\Credentials\Credentials::createFromPlacementRequest( - new \Bitrix24\SDK\Application\Requests\Placement\PlacementRequest($request), - $appProfile -)->getAuthToken()); -// -//$b64 = new \Symfony\Component\Mime\Encoder\Base64Encoder(); -//$str = $b64->encodeString(file_get_contents('bp-82.bpt')); - - -// run workflow -//var_dump($b24Service->getBizProcScope()->template()->delete(82)); - -//$templateId = $b24Service->getBizProcScope()->template()->add( -// WorkflowDocumentType::buildForContact(), -// 'Test template', -// 'Test template description', -// WorkflowAutoExecutionType::withoutAutoExecution, -// 'bp-82.bpt' -//)->getId(); -// -//$updateResult = $b24Service->getBizProcScope()->template()->update( -// $templateId, -// null, -// 'updated name', -// null, -// null, -// 'bp-82.bpt' -//)->isSuccess(); -// -//var_dump($updateResult); - - -// -// -//foreach ($b24Service->getBizProcScope()->activity()->list()->getActivities() as $activityCode) { -// var_dump($activityCode); -// var_dump($b24Service->getBizProcScope()->activity()->delete($activityCode)->isSuccess()); -//} -//$activityCode = 'test_activity'; -//$handlerUrl = 'https://' . $_SERVER['HTTP_HOST'] . '/activity-handler.php'; -//$b24AdminUserId = $b24Service->getMainScope()->main()->getCurrentUserProfile()->getUserProfile()->ID; -//$activityName = [ -// 'ru' => 'НазваниС Π°ΠΊΡ‚ΠΈΠ²ΠΈΡ‚ΠΈ', -// 'en' => 'activity name' -//]; -//$activityDescription = [ -// 'ru' => 'ОписаниС Π°ΠΊΡ‚ΠΈΠ²ΠΈΡ‚ΠΈ', -// 'en' => 'Activity description' -//]; -//$activityProperties = [ -// 'comment' => [ -// 'Name' => [ -// 'ru' => 'строка desc', -// 'en' => 'string desc' -// ], -// 'Description' => [ -// 'ru' => 'строка desc', -// 'en' => 'string desc' -// ], -// 'Type' => WorkflowPropertyType::string->name, -// 'Options' => null, -// 'Required' => 'N', -// 'Multiple' => 'N', -// 'Default' => 'дСфолтная строка - Π·Π½Π°Ρ‡Π΅Π½ΠΈΠ΅' -// -// ], -// 'amount' => [ -// 'Name' => [ -// 'ru' => 'int Π·Π½Π°Ρ‡Π΅Π½ΠΈΠ΅', -// 'en' => 'int value' -// ], -// 'Description' => [ -// 'ru' => 'int Π·Π½Π°Ρ‡Π΅Π½ΠΈΠ΅ ΠΏΡ€ΠΈΠΌΠ΅Ρ€', -// 'en' => 'int value example' -// ], -// 'Type' => WorkflowPropertyType::int->name, -// 'Options' => null, -// 'Required' => 'N', -// 'Multiple' => 'N', -// 'Default' => 333 -// ] -//]; -// -//$activityReturnProperties = [ -// 'result_sum' => [ -// 'Name' => [ -// 'ru' => 'int Π·Π½Π°Ρ‡Π΅Π½ΠΈΠ΅', -// 'en' => 'int value' -// ], -// 'Description' => [ -// 'ru' => 'int', -// 'en' => 'int' -// ], -// 'Type' => WorkflowPropertyType::int->name, -// 'Options' => null, -// 'Required' => 'N', -// 'Multiple' => 'N', -// 'Default' => 444 -// ] -//]; -// -// -//$addActivityResult = $b24Service->getBizProcScope()->activity()->add( -// $activityCode, -// $handlerUrl, -// $b24AdminUserId, -// $activityName, -// $activityDescription, -// true, -// $activityProperties, -// false, -// $activityReturnProperties, -// WorkflowDocumentType::buildForLead(), -// [] -//); -// -//var_dump($addActivityResult->getCoreResponse()->getResponseData()->getResult()); -// -// -// -//print('delete robots...' . PHP_EOL); -//foreach ($b24Service->getBizProcScope()->robot()->list()->getRobots() as $robotCode) { -// print_r($b24Service->getBizProcScope()->robot()->delete($robotCode)->isSuccess()); -//} -// -// -//$robotProperties = [ -// 'comment' => [ -// 'Name' => [ -// 'ru' => 'строка desc', -// 'en' => 'string desc' -// ], -// 'Description' => [ -// 'ru' => 'строка desc', -// 'en' => 'string desc' -// ], -// 'Type' => WorkflowPropertyType::string->name, -// 'Options' => null, -// 'Required' => 'N', -// 'Multiple' => 'N', -// 'Default' => 'дСфолтная строка - Π·Π½Π°Ρ‡Π΅Π½ΠΈΠ΅' -// -// ], -// 'amount' => [ -// 'Name' => [ -// 'ru' => 'int Π·Π½Π°Ρ‡Π΅Π½ΠΈΠ΅', -// 'en' => 'int value' -// ], -// 'Description' => [ -// 'ru' => 'int Π·Π½Π°Ρ‡Π΅Π½ΠΈΠ΅ ΠΏΡ€ΠΈΠΌΠ΅Ρ€', -// 'en' => 'int value example' -// ], -// 'Type' => WorkflowPropertyType::int->name, -// 'Options' => null, -// 'Required' => 'N', -// 'Multiple' => 'N', -// 'Default' => 333 -// ] -//]; -// -//$robotReturnProperties = [ -// 'result_sum' => [ -// 'Name' => [ -// 'ru' => 'int Π·Π½Π°Ρ‡Π΅Π½ΠΈΠ΅', -// 'en' => 'int value' -// ], -// 'Description' => [ -// 'ru' => 'int', -// 'en' => 'int' -// ], -// 'Type' => WorkflowPropertyType::int->name, -// 'Options' => null, -// 'Required' => 'N', -// 'Multiple' => 'N', -// 'Default' => 'дСфолтная строка - Π·Π½Π°Ρ‡Π΅Π½ΠΈΠ΅' -// ] -//]; -// -//$handlerUrl = 'https://' . $_SERVER['HTTP_HOST'] . '/robot-handler.php'; -//var_dump($handlerUrl); -//print('install robots...' . PHP_EOL); -//$addResult = $b24Service->getBizProcScope()->robot()->add('test_r_1', $handlerUrl, -// 1, -// [ -// 'ru' => 'Π ΠžΠ‘ΠžΠ’ 1', -// 'en' => 'robot 1', -// ], -// true, -// $robotProperties, -// false, -// $robotReturnProperties -//); -// -//var_dump($addResult->isSuccess()); -//// -//var_dump($b24Service->getBizProcScope()->robot()->list()->getRobots()); -//// -// diff --git a/examples/application/local/robot-handler.php b/examples/application/local/robot-handler.php deleted file mode 100644 index ab923878..00000000 --- a/examples/application/local/robot-handler.php +++ /dev/null @@ -1,87 +0,0 @@ - -
-    ΠŸΡ€ΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠ΅ Ρ€Π°Π±ΠΎΡ‚Π°Π΅Ρ‚, ΠΏΠΎΠ»ΡƒΡ‡ΠΈΠ»ΠΈ Ρ‚ΠΎΠΊΠ΅Π½Ρ‹ ΠΎΡ‚ Битрикс24:
-    
-
-bootEnv('.env'); - -if ($_SERVER['APP_DEBUG']) { - umask(0000); - - if (class_exists( - Debug::class - )) { - Debug::enable(); - } -} - - -try { - $log = new Logger('bitrix24-php-sdk-cli'); - $log->pushHandler(new StreamHandler($_ENV['LOGS_FILE_NAME'], (int)$_ENV['LOGS_LEVEL'])); - $log->pushProcessor(new MemoryUsageProcessor(true, true)); - - $req = Request::createFromGlobals(); - $log->debug('incoming request', [ - 'payload' => $req->request->all() - ]); - - $b24ServiceFactory = new ServiceBuilderFactory(new EventDispatcher(), $log); - $appProfile = ApplicationProfile::initFromArray($_ENV); - - - $rr = IncomingRobotRequest::initFromRequest($req); - - $b24Service = $b24ServiceFactory->initFromRequest( - $appProfile, - $rr->auth->accessToken, - $rr->auth->domain - ); - - $returnProp = [ - 'result_sum' => 5555 - ]; - - $res = $b24Service->getBizProcScope()->event()->send( - $rr->eventToken, - $returnProp, - sprintf('debug result %s', print_r($returnProp, true)) - ); - $log->debug('ffffffff', [ - 'res' => $res->isSuccess() - ]); - -} catch (Throwable $exception) { - - $log->error(sprintf('error: %s', $exception->getMessage()), [ - 'trace' => $exception->getTraceAsString() - ]); - - -} - - diff --git a/examples/local-application/composer.json b/examples/local-application/composer.json new file mode 100644 index 00000000..f8462c44 --- /dev/null +++ b/examples/local-application/composer.json @@ -0,0 +1,20 @@ +{ + "name": "mesilov/bitrix24-php-sdk-webhook-example", + "description": "Example for work with bitrix24-php-sdk via webhook", + "minimum-stability": "stable", + "license": "proprietary", + "authors": [ + { + "name": "Maksim Mesilov", + "email": "mesilov.maxim@gmail.com" + } + ], + "require": { + "mesilov/bitrix24-php-sdk": "dev-feature/390-prepare-publish-2-0", + "monolog/monolog": "^3", + "symfony/dotenv": "^7" + }, + "require-dev": { + "roave/security-advisories": "dev-latest" + } +} \ No newline at end of file diff --git a/examples/local-application/index.php b/examples/local-application/index.php new file mode 100644 index 00000000..64573a63 --- /dev/null +++ b/examples/local-application/index.php @@ -0,0 +1,36 @@ + +
+    Application is worked, auth tokens from bitrix24:
+    
+
+pushHandler(new StreamHandler('bitrix24-php-sdk.log')); +$log->pushProcessor(new MemoryUsageProcessor(true, true)); + +$b24ServiceBuilderFactory = new ServiceBuilderFactory(new EventDispatcher(), $log); +$appProfile = ApplicationProfile::initFromArray([ + 'BITRIX24_PHP_SDK_APPLICATION_CLIENT_ID' => 'INSERT_HERE_YOUR_DATA', + 'BITRIX24_PHP_SDK_APPLICATION_CLIENT_SECRET' => 'INSERT_HERE_YOUR_DATA', + 'BITRIX24_PHP_SDK_APPLICATION_SCOPE' => 'INSERT_HERE_YOUR_DATA' +]); +$b24Service = $b24ServiceBuilderFactory->initFromRequest($appProfile, AuthToken::initFromPlacementRequest($request), $request->get('DOMAIN')); + +var_dump($b24Service->getMainScope()->main()->getCurrentUserProfile()->getUserProfile()); +// get deals list and address to first element +var_dump($b24Service->getCRMScope()->lead()->list([], [], ['ID', 'TITLE'])->getLeads()[0]->TITLE); \ No newline at end of file diff --git a/examples/application/local/install.php b/examples/local-application/install.php similarity index 53% rename from examples/application/local/install.php rename to examples/local-application/install.php index 31cd5b2a..f5812ca7 100644 --- a/examples/application/local/install.php +++ b/examples/local-application/install.php @@ -1,11 +1,8 @@
-    Установка прилоТСния, ΠΏΠΎΠ»ΡƒΡ‡ΠΈΠ»ΠΈ Ρ‚ΠΎΠΊΠ΅Π½Ρ‹ ΠΎΡ‚ Битрикс24:
+    Application installation started, tokens from Bitrix24: