定制 teleads/sdk-php 二次开发

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

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

teleads/sdk-php

最新稳定版本:v1.1.0

Composer 安装命令:

composer require teleads/sdk-php

包简介

TeleAds SDK

README 文档

README

This repository holds SDK related to TeleAds.

Requirements

  • PHP 5.3 or later
  • ext-sockets

Installation

Install the latest version with

composer require teleads/sdk-php

Installing ext-sockets

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

The TeleAds 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 \TeleAds\Sdk\BAP('<sdk_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, SDK 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 \TeleAds\Sdk\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);

SDK Key

The SDK Key is generated immediately after connecting your Telegram Bot in TeleAds.

You can find more information on the platform configuration here.

About

Submitting bugs and feature requests

Bugs and feature request are tracked on GitLab

License

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

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-04-21

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固