定制 codd-tech/bap-sdk-php 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

codd-tech/bap-sdk-php

Composer 安装命令:

composer require codd-tech/bap-sdk-php

包简介

Bot Advertising Platform SDK

README 文档

README

This repository holds SDK related to Bot Advertising Platform.

Requirements

  • PHP 5.3 or later
  • ext-sockets

Installation

Install the latest version with

composer require codd-tech/bap-sdk-php

Installing ext-sockets

The socket extension implements a low-level interface to the socket communication.

The BAP SDK uses the UDP protocol for data transfer to ensure minimal SDK overhead for the user.

To install socket extension add the following line to your php.ini:

extension=php_sockets.dll

Or add RUN docker-php-ext-install sockets to your project's Dockerfile if you are using official php image.

Usage

SDK accepts single update from the Telegram bot as an associative array.

Basic usage

$bap = new \CoddTech\Bap\BAP('<api key>');
$bap->handleTelegramUpdates($update);

If your advertisement mode is set to manual you can mark ad placement in your code by calling:

$bap->advertisement($update);

Interrupting control flow

At times, BAP may introduce telegram updates within its advertisement flow. To maintain the logical consistency of your bot, it is necessary to ignore such updates.

The BAP::handleTelegramUpdates method returns a boolean value indicating whether you should proceed with handling the request or skip it as an internal BAP request.

When the method returns false, it signifies that the current request should not be processed by your bot.

Usage with PHP Telegram Bot package

If you are using PHP Telegram Bot package you can call SDK inside custom update filter, eg:

$telegram = new Longman\TelegramBot\Telegram($bot_api_key, $bot_username);

$bap = new \CoddTech\Bap\BAP('<api key>');
$telegram->setUpdateFilter(function (Update $update, Telegram $telegram, &$reason = 'Update denied by update_filter') use ($bap) {
    return $bap->handleTelegramUpdates($update->getRawData());
});

For manual advertisement mode(Should be turned on in settings) call following in the desired ad placements.

$bap->advertisement($update);

API Key

API key is not your Telegram bot token.

API key must be obtained from socialjet.pro

About

Submitting bugs and feature requests

Bugs and feature request are tracked on GitHub

License

Bot Advertising Platform SDK is licensed under the MIT License - see the LICENSE file for details

codd-tech/bap-sdk-php 适用场景与选型建议

codd-tech/bap-sdk-php 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 901 次下载、GitHub Stars 达 1, 最近一次更新时间为 2023 年 05 月 31 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 codd-tech/bap-sdk-php 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 901
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 14
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 2
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-05-31