概述

Portex SDK 是一个用于在 Telegram、Web 和其他平台上创建小游戏的开发工具包。

Portex SDK(测试版)

安装

  • https://sdk.portex.app/portex-sdk.min.js 内联到您的小游戏中

  • 或从源代码构建

git clone https://github.com/portex-app/portex-sdk.git
cd portex-sdk

pnpm install
pnpm build

使用方法

注意:这是测试版本,您只能在 Telegram 中使用它。从 Portex CLI 获取应用 ID。

  • 使用您的应用 ID 初始化 Portex SDK

const portex = new Portex({
	appId: 'your-app-id',
})

try {
	const result = await portex.init()

	if (result.status === 'ok') {
		// 初始化成功
		// 获取用户信息
		consle.log(sdk.webApp.initDataUnsafe)
	} else {
		// 初始化失败
	}
} catch (error) {
	console.error(error)
}
  • SDK 演示:https://t.me/portex_app_bot?startapp

SDK 功能

API 参考

源代码

Unexpected error with integration github-files: Integration is not installed on this space

Last updated