本文整理汇总了PHP中OAuth::setRSACertificate方法的典型用法代码示例。如果您正苦于以下问题:PHP OAuth::setRSACertificate方法的具体用法?PHP OAuth::setRSACertificate怎么用?PHP OAuth::setRSACertificate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OAuth
的用法示例。
在下文中一共展示了OAuth::setRSACertificate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: OAuth
//var_dump($privkey);
$csrt = openssl_csr_new($dn, $privkey);
//var_dump($csrt);
openssl_csr_export($csrt, $csrout);
$conscsr = pem2der($csrout);
//var_dump($conscsr);
$privrsakey = file_get_contents($pemfile);
session_start();
// In state=1 the next request should include an oauth_token.
// If it doesn't go back to 0
if (!isset($_GET['oauth_token']) && $_SESSION['state'] == 1) {
$_SESSION['state'] = 0;
}
try {
$oauth = new OAuth($conskey, '', OAUTH_SIG_METHOD_RSASHA1, OAUTH_AUTH_TYPE_URI);
$oauth->setRSACertificate(file_get_contents($pkeyfile));
$oauth->enableDebug();
file_put_contents('php://stderr', print_r($oauth->debugInfo, TRUE));
if (!isset($_GET['oauth_token']) && !$_SESSION['state']) {
$oauth->fetch($req_url, array("oauth_callback" => $callback_url, "certreq" => $conscsr));
parse_str($oauth->getLastResponse(), $request_token_info);
//var_dump($request_token_info);
$_SESSION['secret'] = $request_token_info['oauth_token_secret'];
$_SESSION['state'] = 1;
header('Location: ' . $auth_url . '?oauth_token=' . $request_token_info['oauth_token']);
file_put_contents('php://stderr', print_r($oauth->debugInfo, TRUE));
exit;
} else {
if ($_SESSION['state'] == 1) {
$oauth->setToken($_GET['oauth_token'], $_SESSION['secret']);
$access_token_info = $oauth->getAccessToken($acc_url);
示例2: OAuth
<?php
require 'server.inc';
$x = new OAuth('1234', '', OAUTH_SIG_METHOD_RSASHA1);
$x->setRequestEngine(OAUTH_REQENGINE_STREAMS);
$x->setTimestamp(12345);
$x->setNonce('testing');
$x->setRSACertificate(file_get_contents(dirname(__FILE__) . '/test.pem'));
$port = random_free_port();
$pid = http_server("tcp://127.0.0.1:{$port}", array("HTTP/1.0 200 OK\r\nContent-Type: text/plain\r\nContent-Length: 40\r\n\r\noauth_token=1234&oauth_token_secret=4567"), $output);
$x->setAuthType(OAUTH_AUTH_TYPE_URI);
var_dump($x->getRequestToken("http://127.0.0.1:{$port}/test"));
fseek($output, 0, SEEK_SET);
var_dump(stream_get_contents($output));
http_server_kill($pid);