forked from jeffhodsdon/HTTP_OAuth
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathexamples-config.php
89 lines (73 loc) · 2.25 KB
/
examples-config.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<?php
/**
* HTTP_OAuth
*
* Implementation of the OAuth specification
*
* PHP version 5.2.0+
*
* LICENSE: This source file is subject to the New BSD license that is
* available through the world-wide-web at the following URI:
* http://www.opensource.org/licenses/bsd-license.php. If you did not receive
* a copy of the New BSD License and are unable to obtain it through the web,
* please send a note to [email protected] so we can mail you a copy immediately.
*
* @category HTTP
* @package HTTP_OAuth
* @author Jeff Hodsdon <[email protected]>
* @copyright 2009 Jeff Hodsdon <[email protected]>
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
* @link http://pear.php.net/package/HTTP_OAuth_Provider
* @link http://github.com/jeffhodsdon/HTTP_OAuth_Provider
*/
chdir(dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR);
$base = realpath(dirname(__FILE__) . '/../../') . '/';
set_include_path("{$base}HTTP_OAuth:" . get_include_path());
require_once 'HTTP/OAuth.php';
require_once 'HTTP/OAuth/Consumer/Request.php';
require_once 'HTTP/Request2.php';
//require_once 'Log.php';
//HTTP_OAuth::attachLog(Log::singleton('display'));
/* Configuration for Examples */
class Config
{
private $config = array();
public $isHttp = false;
public function __get($var)
{
if (!array_key_exists($var, $this->config)) {
if ($this->isHttp) {
header('HTTP/1.1 500 Internal Server Error');
}
echo "Missing {$var} option\n";
die(0);
}
return $this->config[$var];
}
public function __set($var, $val)
{
$this->config[$var] = $val;
}
}
$config = new Config;
if (!empty($_GET)) {
$config->isHttp = true;
foreach ($_GET as $name => $val) {
if (empty($val)) {
continue;
}
if (is_array($val)) {
foreach ($val as $n => $v) {
if (!strlen($v)) {
unset($val[$n]);
}
}
}
$config->$name = $val;
}
}
$httpRequest = new HTTP_Request2;
$httpRequest->setHeader('Accept-Encoding', '.*');
$request = new HTTP_OAuth_Consumer_Request;
$request->accept($httpRequest);
?>