定制 elliptic/elliptic-sdk 二次开发

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

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

elliptic/elliptic-sdk

最新稳定版本:v0.9.1

Composer 安装命令:

composer require elliptic/elliptic-sdk

包简介

Elliptic SDK for PHP - A Guzzle wrapper for connecting to Elliptic APIs

README 文档

README

Installation

Composer

composer require elliptic/elliptic-sdk

Usage

The SDK provides an instance of the popular Guzzle HTTP client, adding the necessary steps to authenticate each request using your Elliptic API key and secret.

use Elliptic\AML;

$aml = new AML([
    'key' => 'YOUR_ELLIPTIC_API_KEY',
    'secret' => 'YOUR_ELLIPTIC_API_SECRET',
]);

// $aml->client is an instance of GuzzleHttp\Client
$response = $aml->client->get('/v2/analyses');

Webhook Signature Verification

Elliptic signs the webhook events it sends to your endpoint, allowing you to validate that they were not sent by a third-party. You can use the WebhookRequestVerifier class to verify the signature of a webhook request:

<?php

use Elliptic\WebhookRequestVerifier;

require 'vendor/autoload.php';

$options = [
    'trustedPublicKey' => "<This can be found from Elliptic's docs>",
    'expectedEndpointId' =>   "<This will be provided when your webhook integration is set up by Elliptic>",
];

$verifier = new WebhookRequestVerifier($options);

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    try {
        $webhookIdHeader = $_SERVER['HTTP_WEBHOOK_ID'];
        $webhookTimestampHeader = $_SERVER['HTTP_WEBHOOK_TIMESTAMP'];
        $webhookSignatureHeader = $_SERVER['HTTP_WEBHOOK_SIGNATURE'];
        $reqBody = file_get_contents('php://input');

        $params = [
            'webhookIdHeader' => $webhookIdHeader,
            'webhookTimestampHeader' => $webhookTimestampHeader,
            'webhookSignatureHeader' => $webhookSignatureHeader,
            'reqBody' => $reqBody,
        ];

        $messageId = $verifier->verify($params);
        echo("Verification successful, message ID: $messageId");
        http_response_code(200);
    } catch (Exception $e) {
        echo "Verification failed: " . $e->getMessage();
        http_response_code(401);
    }
} else {
    http_response_code(405);
    echo "Only POST requests are allowed.";
}

API Documentation

Documentation for Elliptic APIs can be found at the Elliptic Developer Center

License

This SDK is distributed under the Apache License, Version 2.0, see LICENSE and NOTICE for more information.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2023-05-04