ujy/bitrix24_api_authorization 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

ujy/bitrix24_api_authorization

Composer 安装命令:

composer require ujy/bitrix24_api_authorization

包简介

Authorization class to easy get Bitrix24 Access Tokens for use in API

README 文档

README

License Total Downloads Latest Stable Version Latest Unstable Version

Big thanks to opravdin for the global class FIX which returned class back to life after Bitrix24 team changed their login page UI in February 2019...

Read this document on other languages: English, Русский.

Tiny class to make Bitrix24 authorization process automated. Just define few vars and get Bitrix24 access token (session token) in automatic way.

  • You can use it as separated class
  • You can use it in pair with mesilov/bitrix24-php-sdk - great lib for work with Bitrix24 API.

Requirements

Example "as separated class"

<?php
require_once 'vendor/autoload.php';

$b24auth = new \Bitrix24Authorization\Bitrix24Authorization();

// Change example data to your own
$b24auth->setApplicationId('local.1b1231b1xfa234.12352734'); // Getting when registring Bitrix24 application
$b24auth->setApplicationSecret('q3vOqweJSasd1wDAkdL3qq13rqKDe8ffGMlFsI8Ykpasld4n0w'); // Getting when registring Bitrix24 application
$b24auth->setApplicationScope('crm,user,telephony'); // write Bitrix24 instances which you want to use via API. They need to be choosen in application at Bitrix24
$b24auth->setBitrix24Domain('your-site.bitrix24.ru'); // Address of your Bitrix24 portal
$b24auth->setBitrix24Login('your_login@gmail.com'); // login of your real user, he need to be an Admibistrator of instance you want to use
$b24auth->setBitrix24Password('your_password'); // password of your real user, he need to be an Admibistrator of instance you want to use

$b24auth->initialize();

// Now you can use object $b24auth

var_dump($b24auth->bitrix24_access); // Here you`ve got your authorization data
// Or you can just use $b24auth->initialize() - it will return the same data as property "bitrix24_access". Access token will not RE generated until it expires
?>

Output will be like this:

object(stdClass)#2 (11) {
  ["access_token"]=>
  string(70) "d69d585b0027431000005e120000011c000003b69bb7c48c33547a3b053d21a5c1d0f5"
  ["expires"]=>
  int(1532534230)
  ["expires_in"]=>
  int(3600)
  ["scope"]=>
  string(18) "crm,user,telephony"
  ["domain"]=>
  string(18) "your-site.bitrix24.ru"
  ["server_endpoint"]=>
  string(31) "https://oauth.bitrix.info/rest/"
  ["status"]=>
  string(1) "L"
  ["client_endpoint"]=>
  string(32) "https://your-site.bitrix24.ru/rest/"
  ["member_id"]=>
  string(32) "02f2213319a5e74fb12351c15345fe81"
  ["user_id"]=>
  int(1)
  ["refresh_token"]=>
  string(70) "c61c805b0027431000005e120000011c000003e02d1b4a9ce34e617d09cecbf6e69efb"
}

Example "as part of mesilov/bitrix24-php-sdk library"

<?php
require_once 'vendor/autoload.php';

// Initializing object from mesilov/bitrix24-php-sdk library
$mesilov_obj = new \Bitrix24\Bitrix24();

// Initializing authorization class
$b24auth = new \Bitrix24Authorization\Bitrix24Authorization();

// Change example data to your own
$b24auth->setApplicationId('local.1b1231b1xfa234.12352734'); // Getting when registring Bitrix24 application
$b24auth->setApplicationSecret('q3vOqweJSasd1wDAkdL3qq13rqKDe8ffGMlFsI8Ykpasld4n0w'); // Getting when registring Bitrix24 application
$b24auth->setApplicationScope('crm,user,telephony'); // write Bitrix24 instances which you want to use via API. They need to be choosen in application at Bitrix24
$b24auth->setBitrix24Domain('your-site.bitrix24.ru'); // Address of your Bitrix24 portal
$b24auth->setBitrix24Login('your_login@gmail.com'); // login of your real user, he need to be an Admibistrator of instance you want to use
$b24auth->setBitrix24Password('your_password'); // password of your real user, he need to be an Admibistrator of instance you want to use

// Initializing
$mesilov_auth_obj = $b24auth->initialize($mesilov_obj);
/* Initializing with mesilov object as parameter call next methods of mesilov/bitrix24-php-sdk library:
    $mesilov_obj->setApplicationScope();
    $mesilov_obj->setApplicationId();
    $mesilov_obj->setApplicationSecret();
    $mesilov_obj->setDomain();
    $mesilov_obj->setMemberId();
    $mesilov_obj->setAccessToken();
    $mesilov_obj->setRefreshToken();
*/

// Now we can work with Bitrix24 API using library
// EXAMPLE: Lets get info about current user, who was used in authorization process
$obB24User = new \Bitrix24\User\User($mesilov_auth_obj);
$arCurrentB24User = $obB24User->current();

var_dump($arCurrentB24User);

Installation

Add "ujy/bitrix24_api_authorization": "dev-master" to composer.json of your application. Or clone repo to your project.

Or just use composer command "composer require ujy/bitrix24_api_authorization:dev-master

Submitting bugs and feature requests

Bugs and feature request are tracked on GitHub

License

Current class is licensed under the MIT License - see the LICENSE file for details

Author

Ievgenii Gardysh - ujy@ukr.net / ghenia.hard@gmail.com
Oleg Pravdin (class rewriter after bitrix UI update) - opravdin@gmail.com

Thanks to Sergey from afinogen.su for base version of script which gets access token in automated way.

Have any questions?

email: ujy@ukr.net / ghenia.hard@gmail.com
email: opravdin@gmail.com

ujy/bitrix24_api_authorization 适用场景与选型建议

ujy/bitrix24_api_authorization 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2k 次下载、GitHub Stars 达 16, 最近一次更新时间为 2018 年 07 月 26 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「api」 「access」 「token」 「Bitrix24」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 ujy/bitrix24_api_authorization 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 ujy/bitrix24_api_authorization 我们能提供哪些服务?
定制开发 / 二次开发

基于 ujy/bitrix24_api_authorization 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 2k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 16
  • 点击次数: 18
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 16
  • Watchers: 3
  • Forks: 8
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-07-26