承接 verifymyagecouk/verifymyage-oauth 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

verifymyagecouk/verifymyage-oauth

最新稳定版本:3.0.8

Composer 安装命令:

composer create-project verifymyagecouk/verifymyage-oauth

包简介

VerifyMyAge OAuth Verification

README 文档

README

A PHP SDK for integrating with VerifyMyAge's verification service. This library provides easy-to-use methods for implementing age verification in your PHP applications.

Table of Contents

Installation

composer require verifymyagecouk/verifymyage-oauth

Features

  • Authentication flow
  • Multiple verification methods
  • Support for various countries
  • Sandbox environment for testing
  • HMAC authentication
  • User data encryption

Usage

Basic Setup

use VerifyMyAge\OAuth;

// Initialize the OAuth client
$oauth = new OAuth(
    'your-client-id',
    'your-client-secret',
    'your-redirect-url'
);

// For development/testing, use sandbox mode
$oauth->useSandbox();

Available Methods

The SDK provides three different versions of the OAuth implementation:

  1. OAuth (Legacy):
use VerifyMyAge\OAuth;
$oauth = new OAuth($clientId, $clientSecret, $redirectUrl);
  1. OAuthV1:
use VerifyMyAge\OAuthV1;
$oauth = new OAuthV1($clientId, $clientSecret, $redirectUrl);
  1. OAuthV2 (Recommended):
use VerifyMyAge\OAuthV2;
$oauth = new OAuthV2($clientId, $clientSecret, $redirectUrl);

Verification Methods

Available verification methods:

Methods::AGE_ESTIMATION
Methods::CREDIT_CARD
Methods::ID_SCAN
Methods::ID_SCAN_FACE_MATCH
Methods::EMAIL

Starting Verification (OAuthV2)

$result = $oauth->getStartVerificationUrl(
    country: Countries::UNITED_KINGDOM,
    method: Methods::ID_SCAN,
    businessSettingsId: 'your-business-settings-id',
    externalUserId: 'user-123',
    verificationId: 'verification-123',
    webhook: 'https://your-webhook.com/callback',
    stealth: false,
    userInfo: [
        'email' => 'user@example.com'
        // Additional user information
    ]
);

Handling the OAuth Flow

  1. Generate Authorization URL:
$authUrl = $oauth->redirectURL(
    country: Countries::UNITED_KINGDOM,
    method: Methods::ID_SCAN
);
  1. Exchange Code for Token:

After the user completes the verification process with us, we will redirect the user back to you using your redirect URL provided to us in the first step, we will keep all the query strings you've sent and also add two new ones, First as code and Second as verification_id. The code must be used in this function, so we can authenticate your request and identify the verification that you want to get the result.

$token = $oauth->exchangeCodeByToken($code);

Supported Countries

The SDK supports various countries including:

  • United Kingdom (Countries::UNITED_KINGDOM)
  • France (Countries::FRANCE)
  • Germany (Countries::GERMANY)
  • United States (Countries::UNITED_STATES_OF_AMERICA)
  • Italy (Countries::ITALY)
  • Demo mode (Countries::DEMO)

Development Mode

For testing and development, use the sandbox environment:

$oauth->useSandbox();

This will direct all requests to the sandbox API endpoint.

Complete Example

Here's a complete example of implementing age verification:

<?php

use VerifyMyAge\OAuthV2;
use VerifyMyAge\Countries;
use VerifyMyAge\Methods;

// Initialize the OAuth client
$oauth = new OAuthV2(
    clientID: 'your-client-id',
    clientSecret: 'your-client-secret',
    redirectURL: 'https://your-app.com/callback'
);

// Use sandbox for development
$oauth->useSandbox();

// Start verification process
$verificationResult = $oauth->getStartVerificationUrl(
    country: Countries::UNITED_KINGDOM,
    method: Methods::ID_SCAN,
    businessSettingsId: 'your-business-id',
    externalUserId: 'user-123',
    webhook: 'https://your-app.com/webhook'
);

// Handle the verification response
if (isset($verificationResult['verification_url'])) {
    // Redirect user to verification URL
    header('Location: ' . $verificationResult['verification_url']);
    exit;
}

Verification Status (OAuthV1 & OAuthV2)

For detailed information about how to check the verification status, please refer to the official documentation: Verification Status Documentation

Security Considerations

  • Always use HTTPS for redirect URLs
  • Keep your client credentials secure
  • Validate all user input
  • Implement proper error handling
  • Use webhook validation for callbacks

Error Handling

The SDK throws exceptions for invalid inputs or API errors. Always wrap API calls in try-catch blocks:

try {
    $result = $oauth->getStartVerificationUrl(...);
} catch (\Exception $e) {
    // Handle the error appropriately
    error_log($e->getMessage());
}

统计信息

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

GitHub 信息

  • Stars: 3
  • Watchers: 3
  • Forks: 4
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固