discord/interactions 问题修复 & 功能扩展

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

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

discord/interactions

最新稳定版本:2.2.0

Composer 安装命令:

composer require discord/interactions

包简介

Utils for implementing the Discord Interactions API

关键字:

README 文档

README

Types and helper functions that may come in handy when you implement a Discord Interactions webhook.

Installation

Install from packagist:

composer require discord/interactions

Validating request signatures requires the simplito/elliptic-php package to be installed, which requires the php-gmp extension to be enabled:

composer require simplito/elliptic-php

Usage

Use InteractionType and InteractionResponseType to interpret and respond to webhooks.

Use InteractionResponseFlags to make your response special.

Use verifyKey to check a request signature. Note you must install the simplito/elliptic-php package first. For example:

use Discord\Interaction;
use Discord\InteractionResponseType;

$CLIENT_PUBLIC_KEY = getenv('CLIENT_PUBLIC_KEY');

$signature = $_SERVER['HTTP_X_SIGNATURE_ED25519'];
$timestamp = $_SERVER['HTTP_X_SIGNATURE_TIMESTAMP'];
$postData = file_get_contents('php://input');

if (Interaction::verifyKey($postData, $signature, $timestamp, $CLIENT_PUBLIC_KEY)) {
  echo json_encode(array(
    'type' => InteractionResponseType::PONG
  ));
} else {
  http_response_code(401);
  echo "Not verified";
}

统计信息

  • 总下载量: 325.01k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 45
  • 点击次数: 1
  • 依赖项目数: 7
  • 推荐数: 0

GitHub 信息

  • Stars: 45
  • Watchers: 10
  • Forks: 14
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-12-12