x3group-dev/bitrix24-api
Composer 安装命令:
composer require x3group-dev/bitrix24-api
包简介
Bitrix24 rest api
README 文档
README
Обертка для работы с REST API Битрикс24
Установка
composer require x3group-dev/bitrix24-api
Пример вызова
use Bitrix24Api\ApiClient;
use Bitrix24Api\Config\Application;
use Bitrix24Api\Config\Config;
use Bitrix24Api\Config\Credential;
use Bitrix24Api\Models\ProfileModel;
use Monolog\Handler\StreamHandler;
use Monolog\Logger;
try {
$application = new Application('local.61efad2c1b9651.84092660', 'yUMINzBh99gHYu5aZcE5ui2e6M0ylR23Ouwg1RzKasv7DYhov1');
$credential = Credential::initFromArray([
'access_token' => 'c6d91962005924exxxxxxxxxxxx6ed53e582b4963a890e9fe9',
'expires' => 1643362553,
'domain' => 'domain.bitrix24.ru',
'server_endpoint' => 'https://oauth.bitrix24.tech/rest/',
'client_endpoint' => 'https://domain.bitrix24.ru/rest/',
'member_id' => 'd8ec73fxxxxxxxxxxxc9f52588fca4d',
'user_id' => 3,
'refresh_token' => 'b6584162005924exxxxxxxxxxx003b8cc7f3196b8e823af463169b888e2a1',
'status' => ''
]);
$logger = new Logger('name');
$logger->pushHandler(new StreamHandler('debug.log', Logger::DEBUG));
$config = new Config(null, $application, $credential, $logger);
$api = new ApiClient($config);
$api->onAccessTokenRefresh(function (Credential $credential) {
echo '<pre>';
print_r($credential->toArray());
echo '</pre>';
});
/** @var ProfileModel $profile */
$profile = $api->profile()->call();
if($profile) {
echo '<pre>';
print_r($profile->getName());
echo '</pre>';
}
} catch (\Bitrix24Api\Exceptions\ExpiredRefreshToken $exception){
echo 'ExpiredRefreshToken';
} catch (\Exception $exception) {
echo '<pre>';
print_r($exception->getMessage());
echo '</pre>';
}
Пример вызова через вебхук
use Bitrix24Api\ApiClient;
use Bitrix24Api\Config\Application;
use Bitrix24Api\Config\Config;
use Bitrix24Api\Config\Credential;
use Bitrix24Api\Models\ProfileModel;
use Monolog\Handler\StreamHandler;
use Monolog\Logger;
try {
$logger = new Logger('name');
$logger->pushHandler(new StreamHandler('debug.log', Logger::DEBUG));
$config = new Config('https://xxxxxxxx.bitrix24.ru/', null, null, $logger);
$api = new ApiClient($config);
/** @var ProfileModel $profile */
$profile = $api->profile()->call();
if($profile) {
echo '<pre>';
print_r($profile->getName());
echo '</pre>';
}
} catch (\Exception $exception) {
echo '<pre>';
print_r($exception->getMessage());
echo '</pre>';
}
Пример выполнения batch
$batch = $api->batch();
$batch->addCommand('profile',[]);
foreach ($batch->call() as $batchResult)
{
}
x3group-dev/bitrix24-api 适用场景与选型建议
x3group-dev/bitrix24-api 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 319 次下载、GitHub Stars 达 2, 最近一次更新时间为 2023 年 07 月 10 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 x3group-dev/bitrix24-api 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 x3group-dev/bitrix24-api 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 319
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-07-10