codeauth/codeauth-sdk 问题修复 & 功能扩展

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

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

codeauth/codeauth-sdk

最新稳定版本:v1.2.0

Composer 安装命令:

composer require codeauth/codeauth-sdk

包简介

Official CodeAuth PHP SDK

README 文档

README

Latest Stable Version Total Downloads License

Offical CodeAuth SDK. For more info, check the docs on our official website.

Install

You can install the bindings via Composer. Run the following command:

composer require codeauth/codeauth-sdk

To use the bindings, use Composer's autoload:

require_once 'vendor/autoload.php';

Basic Usage

Initialize CodeAuth SDK

use CodeAuth\CodeAuth;
CodeAuth::Initialize("<your project API endpoint>", "<your project ID>");

Signin / Email

Begins the sign in or register flow by sending the user a one time code via email.

$result = CodeAuth::SignInEmail("<user email>");
switch ($result["error"])
{
	case "bad_json": print("bad_json"); break;
	case "project_not_found": print("project_not_found"); break;
	case "bad_ip_address": print("bad_ip_address"); break;
	case "rate_limit_reached": print("rate_limit_reached"); break;
	case "bad_email": print("bad_email"); break;
	case "code_request_interval_reached": print("code_request_interval_reached"); break;
	case "code_hourly_limit_reached": print("code_hourly_limit_reached"); break;
	case "email_provider_error": print("email_provider_error"); break;
	case "internal_error": print("internal_error"); break;
	case "connection_error": print("connection_error"); break; //sdk failed to connect to api server
}

Signin / Email Verify

Checks if the one time code matches in order to create a session token.

$result = CodeAuth::SignInEmailVerify("<user email>", "<one time code>");
switch ($result["error"])
{
	case "bad_json": print("bad_json"); break;
	case "project_not_found": print("project_not_found"); break;
	case "bad_ip_address": print("bad_ip_address"); break;
	case "rate_limit_reached": print("rate_limit_reached"); break;
	case "bad_email": print("bad_email"); break;
	case "bad_code": print("bad_code"); break;
	case "internal_error": print("internal_error"); break;
	case "connection_error": print("connection_error"); break; //sdk failed to connect to api server
}
print($result["session_token"]);
print($result["email"]);
print($result["expiration"]);
print($result["refresh_left"]);

Signin / Social

Begins the sign in or register flow by allowing users to sign in through a social OAuth2 link.

$result = CodeAuth::SignInSocial("<social_type>");
switch ($result["error"])
{
	case "bad_json": print("bad_json"); break;
	case "project_not_found": print("project_not_found"); break;
	case "bad_ip_address": print("bad_ip_address"); break;
	case "rate_limit_reached": print("rate_limit_reached"); break;
	case "bad_social_type": print("bad_social_type"); break;
	case "internal_error": print("internal_error"); break;
	case "connection_error": print("connection_error"); break; //sdk failed to connect to api server
}
print($result["signin_url"]);

Signin / Social Verify

This is the next step after the user signs in with their social account. This request checks the authorization code given by the social media company in order to create a session token.

$result = CodeAuth::SignInSocialVerify("<social type>", "<code>");
switch ($result["error"])
{
	case "bad_json": print("bad_json"); break;
	case "project_not_found": print("project_not_found"); break;
	case "bad_ip_address": print("bad_ip_address"); break;
	case "rate_limit_reached": print("rate_limit_reached"); break;
	case "bad_social_type": print("bad_social_type"); break;
	case "bad_authorization_code": print("bad_code"); break;
	case "internal_error": print("internal_error"); break;
	case "connection_error": print("connection_error"); break; //sdk failed to connect to api server
}
print($result["session_token"]);
print($result["email"]);
print($result["expiration"]);
print($result["refresh_left"]);

Session / Info

Gets the information associated with a session token.

$result = CodeAuth::SessionInfo("<session_token>");
switch ($result["error"])
{
	case "bad_json": print("bad_json"); break;
	case "project_not_found": print("project_not_found"); break;
	case "bad_ip_address": print("bad_ip_address"); break;
	case "rate_limit_reached": print("rate_limit_reached"); break;
	case "bad_session_token": print("bad_session_token"); break;
	case "internal_error": print("internal_error"); break;
	case "connection_error": print("connection_error"); break; //sdk failed to connect to api server
}
print($result["email"]);
print($result["expiration"]);
print($result["refresh_left"]);

Session / Refresh

Create a new session token using existing session token.

$result = CodeAuth::SessionRefresh("<session_token>");
switch ($result["error"])
{
	case "bad_json": print("bad_json"); break;
	case "project_not_found": print("project_not_found"); break;
	case "bad_ip_address": print("bad_ip_address"); break;
	case "rate_limit_reached": print("rate_limit_reached"); break;
	case "bad_session_token": print("bad_session_token"); break;
	case "out_of_refresh": print("out_of_refresh"); break;
	case "internal_error": print("internal_error"); break;
	case "connection_error": print("connection_error"); break;//sdk failed to connect to api server
}
print($result["session_token"]);
print($result["email"]);
print($result["expiration"]);
print($result["refresh_left"]);

Session / Invalidate

Invalidate a session token. By doing so, the session token can no longer be used for any api call.

$result = CodeAuth::SessionInvalidate("<session_token>", "<invalidate_type>");
switch ($result["error"])
{
	case "bad_json": print("bad_json"); break;
	case "project_not_found": print("project_not_found"); break;
	case "bad_ip_address": print("bad_ip_address"); break;
	case "rate_limit_reached": print("rate_limit_reached"); break;
	case "bad_session_token": print("bad_session_token"); break;
	case "bad_invalidate_type": print("bad_invalidate_type"); break;
	case "internal_error": print("internal_error"); break;
	case "connection_error": print("connection_error"); break; //sdk failed to connect to api server 
}

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-11-23