-
-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #375 from mesilov/371-publish-b24-php-sdk-beta-2
371 publish b24 php sdk beta 2
- Loading branch information
Showing
7 changed files
with
105 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,4 +7,5 @@ composer.lock | |
tools/.env.local | ||
tools/logs | ||
examples/logs | ||
*.log | ||
.env.local |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# bitrix24 webhook url | ||
BITRIX24_WEBHOOK_URL= | ||
# monolog | ||
LOG_LEVEL=100 | ||
LOG_FILE_NAME=bitrix24-php-sdk.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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": "[email protected]" | ||
} | ||
], | ||
"require": { | ||
"mesilov/bitrix24-php-sdk": "dev-371-publish-b24-php-sdk-beta-2", | ||
"monolog/monolog": "3.5.*", | ||
"symfony/dotenv": "7.0.*" | ||
}, | ||
"require-dev": { | ||
"roave/security-advisories": "dev-latest" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
use Bitrix24\SDK\Services\ServiceBuilderFactory; | ||
use Monolog\Handler\StreamHandler; | ||
use Monolog\Logger; | ||
use Monolog\Processor\IntrospectionProcessor; | ||
use Monolog\Processor\MemoryUsageProcessor; | ||
use Symfony\Component\Dotenv\Dotenv; | ||
use Symfony\Component\EventDispatcher\EventDispatcher; | ||
|
||
require_once 'vendor/autoload.php'; | ||
|
||
// load credentials for work with bitrix24 portal | ||
(new Dotenv())->loadEnv('.env'); | ||
$webhookUrl = $_ENV['BITRIX24_WEBHOOK_URL']; | ||
|
||
// configure logger for debug queries | ||
$log = new Logger('bitrix24-php-sdk'); | ||
$log->pushHandler(new StreamHandler($_ENV['LOG_FILE_NAME'], (int)$_ENV['LOG_LEVEL'])); | ||
$log->pushProcessor(new MemoryUsageProcessor(true, true)); | ||
$log->pushProcessor(new IntrospectionProcessor()); | ||
|
||
// create factory for build service from multiple sources: webhook, request, bitrix24 account with oauth2.0 tokens | ||
$b24ServiceFactory = new ServiceBuilderFactory(new EventDispatcher(), $log); | ||
// init bitrix24-php-sdk service with webhook credentials | ||
$b24Service = $b24ServiceFactory->initFromWebhook($webhookUrl); | ||
|
||
$deal = $b24Service->getCRMScope()->deal()->get(1)->deal(); | ||
var_dump($deal->TITLE); |