kuzm1ch-dev/bitrix24-api-laravel

1.0.16 2024-09-23 12:09 UTC

This package is auto-updated.

Last update: 2024-09-23 12:10:06 UTC


README

laravel 包,方便与 Bitrix24 REST API 交互及应用程序编写

包括以下内容

  • 用于收集请求统计信息和保存用户授权(令牌)的迁移
  • 根据应用程序类型和请求设置的路线
  • 安装和运行应用程序的模板
  • 检查已安装应用程序的门户状态
  • 自动更新用户令牌

安装

composer require x3group-dev/bitrix24-api-laravel

执行发布(复制 routes 和 blade)

php artisan vendor:publish --provider="\X3Group\B24Api\Providers\B24ApiServiceProvider"

执行迁移

php artisan migrate

在应用程序地址中填写

应用程序

https://host/app

安装应用程序

https://host/install

在 .env 文件中添加并填写您的数据

B24API_CLIENT_ID=
B24API_CLIENT_SECRET=

在构建前端时,添加在标题中传递授权以使 b24appFrontRequest 路由工作

BX24.ready(async function () {
    await BX24.init(async function () {
        window.axios.defaults.headers.common['X-b24api-access-token'] = BX24.getAuth().access_token;
        window.axios.defaults.headers.common['X-b24api-domain'] = BX24.getAuth().domain;
        window.axios.defaults.headers.common['X-b24api-member-id'] = BX24.getAuth().member_id;
    });
});

Cron

自动更新应用程序令牌必须添加 crontab 记录

* * * * * cd /path-to-your-project && php artisan schedule:run >> /dev/null 2>&1