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
其他信息
- 授权协议: Apache-2.0
- 更新时间: 2023-05-04