duncan3dc/oauth 问题修复 & 功能扩展

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

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

duncan3dc/oauth

Composer 安装命令:

composer require duncan3dc/oauth

包简介

Handles basic OAuth/OAuth2 authentication along with classes for common services

README 文档

README

Handles non-web based OAuth/OAuth2 authentication along with providers for common services

Latest Stable Version build Coverage Status

I really don't think you will find these classes useful, if you proceed then don't say I didn't warn you
You are likely looking for thephpleague/oauth1-client or thephpleague/oauth2-client

Requirements

  • These classes require use of the sql-class project (for storing authorised credentials)
  • The active database must contain a table called oauth (or know about it via the definitions within the Sql class)
  • The table must have the following schema
`type`      varchar(20),
`username`  varchar(100),
`state`     int(11),
`token`     varchar(100),
`secret`    varchar(100),
UNIQUE KEY `type, username` (`type`,`username`)

OAuth2

The OAuth2 classes require manual intervention to get authorised initially, but once your token/secret are in the database they work like the OAuth classes.

Examples

Basic twitter example

use duncan3dc\OAuth\Twitter;
use duncan3dc\SqlClass\Sql;

Sql::addServer("twitter", [
    "hostname"  =>  "example.com",
    "username"  =>  "my_twitter_app",
    "password"  =>  "secret_password",
    "database"  =>  "twitter",
]);

$twitter = new Twitter([
    "username"  =>  "my_handle",
    "authkey"   =>  "XfHrRTY25FgkyqxDfbpe",
    "secret"    =>  "gwj8c29GHDWdphmQhGtHPx4GybwRfhXplT3CD0VG1n",
]);

# The authorise method returns null if we are already authorised. Otherwise it returns a url to grant at
if ($url = $twitter->authorise()) {
    throw new \Exception("Authorsation failed, grant permission here: " . $url);
}

$userData = $twitter->user("my_handle");
print_($userData);

If you have extended the Sql class (or are using an interface compatible project) you can have the OAuth classes use that class as so

use duncan3dc\OAuth\Twitter;
use MrCoder\MyCustom\Sql;

\duncan3dc\OAuth\Sql::useClass(Sql::class);

$twitter = new Twitter([

If your oauth table is not in the active database, then you can let the Sql class know where it is using the following

use duncan3dc\OAuth\Twitter;
use duncan3dc\SqlClass\Sql;

Sql::addServer("twitter", [
    "hostname"      =>  "example.com",
    "username"      =>  "my_twitter_app",
    "password"      =>  "secret_password",
    "database"      =>  "twitter",
    "definitions"   =>  ["oauth" => "my_other_database"],
]);

$twitter = new Twitter([

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2014-06-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固