定制 dan-rogers/oauth-php 二次开发

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

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

dan-rogers/oauth-php

最新稳定版本:v1.0.2

Composer 安装命令:

composer require dan-rogers/oauth-php

包简介

Library for OAuth 1 and OAuth 2 workflows.

README 文档

README

A PHP Library for OAuth 1 and OAuth 2 workflows.

Installation

composer require dan-rogers/oauth-php

Usage

OAuth 1 Example

  • Use an array of options to create a config for your auth generation.
  • Construct a new OAuth1Config object and use the array as the argument.
  • Construct a new OAuth1 object and use your OAuth1Config object as the argument.
  • Call generateAuthorization().

So long as you have provided the correct information for the OAuth1 step you are on, it will generate a valid auth header.

For more information on OAuth 1 usage see:

#!/usr/bin/php
<?php

use OAuth\OAuth1\OAuth1;
use OAuth\OAuth1\OAuth1Config;

require __DIR__ . '/vendor/autoload.php';

$config  = new OAuth1Config([
    'oauth_callback' => 'https://my_website/my_service/auth',
    'oauth_consumer_key' => 'CONSUMER_KEY',
    'consumer_secret' => 'CONSUMER_SECRET',
    'realm' => 'MY_REALM',
    'oauth_signature_method' => OAuth1Config::HMAC_SHA256,
]);

$oauth = new OAuth1($config);
$auth_header = $oauth->generateAuthorization('https://third_party/token_endpoint', 'POST');

// Example usage using PHP CURL

$ch = curl_init();
curl_setopt_array($ch, [
    CURLOPT_URL => 'https://third_party/token_endpoint',
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_HTTPHEADER => [
        'Authorization: ' . $auth_header,
        'Content-Length: 0',
    ],
]);

$response = curl_exec($ch);

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-07-10

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固