jublonet/oauth-validator-php

一个用于验证PHP中OAuth签名的库。

1.0.1 2014-12-04 20:27 UTC

This package is not auto-updated.

Last update: 2024-09-25 01:32:16 UTC


README

一个用于验证PHP中OAuth签名的库。

版权 (C) 2014 Jublo Solutions support@jublo.net

本程序是免费软件:您可以按照自由软件基金会发布的GNU通用公共许可证的条款重新分发和/或修改它,许可证版本可以是3,也可以是您选择的任何较新版本。

本程序的分发是希望它有用,但没有任何保证;甚至没有关于其可销售性或适用于特定目的的暗示性保证。有关详细信息,请参阅GNU通用公共许可证。

您应该已随本程序收到GNU通用公共许可证的副本。如果没有,请参阅https://gnu.ac.cn/licenses/

要求

  • PHP 5.3.0或更高版本

验证OAuth签名

要验证OAuth签名,请提供消费者密钥和秘密,以及令牌。

require_once 'oauth-validator.php';

\Jublo\Oauth_Validator::setConsumerKey('******', '******');
$ov = \Jublo\Oauth_Validator::getInstance();
$ov->setToken("******", "******");

$params = array(
    'status' => 'Hashtags are cool, when they work. http://www.example.com/gear#id=3&type=store'
);

$authorization = 'OAuth oauth_consumer_key="******", oauth_nonce="6f8b2bc8", oauth_signature="DRicJWVJQFOxdnRgh7hsyvqd8sQ%3D", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1416406562", oauth_token="******", oauth_version="1.0"';

$reply = $ov->validate($authorization, 'POST', 'https://api.twitter.com/1.1/statuses/update.json', $params);
var_dump($reply);