├── CHANGELOG
├── LICENSE
├── README.md
├── VERSION
├── composer.json
├── lib
├── Semantics3.php
├── Semantics3
│ ├── ApiConnector.php
│ ├── AuthenticationError.php
│ ├── Error.php
│ ├── ParameterError.php
│ └── Products.php
└── oauth-php
│ ├── LICENSE
│ ├── README
│ ├── example
│ ├── client
│ │ ├── googledocs.php
│ │ ├── twolegged.php
│ │ ├── twoleggedtest.php
│ │ └── twoleggedtwitter.php
│ └── server
│ │ ├── INSTALL
│ │ ├── core
│ │ ├── init.php
│ │ └── templates
│ │ │ ├── inc
│ │ │ ├── footer.tpl
│ │ │ └── header.tpl
│ │ │ ├── index.tpl
│ │ │ ├── logon.tpl
│ │ │ └── register.tpl
│ │ └── www
│ │ ├── hello.php
│ │ ├── index.php
│ │ ├── logon.php
│ │ ├── oauth.php
│ │ ├── register.php
│ │ └── services.xrds.php
│ ├── library
│ ├── OAuthDiscovery.php
│ ├── OAuthException2.php
│ ├── OAuthRequest.php
│ ├── OAuthRequestLogger.php
│ ├── OAuthRequestSigner.php
│ ├── OAuthRequestVerifier.php
│ ├── OAuthRequester.php
│ ├── OAuthServer.php
│ ├── OAuthSession.php
│ ├── OAuthStore.php
│ ├── body
│ │ ├── OAuthBodyContentDisposition.php
│ │ └── OAuthBodyMultipartFormdata.php
│ ├── discovery
│ │ ├── xrds_parse.php
│ │ └── xrds_parse.txt
│ ├── session
│ │ ├── OAuthSessionAbstract.class.php
│ │ └── OAuthSessionSESSION.php
│ ├── signature_method
│ │ ├── OAuthSignatureMethod.class.php
│ │ ├── OAuthSignatureMethod_HMAC_SHA1.php
│ │ ├── OAuthSignatureMethod_MD5.php
│ │ ├── OAuthSignatureMethod_PLAINTEXT.php
│ │ └── OAuthSignatureMethod_RSA_SHA1.php
│ └── store
│ │ ├── OAuthStore2Leg.php
│ │ ├── OAuthStoreAbstract.class.php
│ │ ├── OAuthStoreAnyMeta.php
│ │ ├── OAuthStoreMySQL.php
│ │ ├── OAuthStoreMySQLi.php
│ │ ├── OAuthStoreOracle.php
│ │ ├── OAuthStorePDO.php
│ │ ├── OAuthStorePostgreSQL.php
│ │ ├── OAuthStoreSQL.php
│ │ ├── OAuthStoreSession.php
│ │ ├── mysql
│ │ ├── install.php
│ │ └── mysql.sql
│ │ ├── oracle
│ │ ├── OracleDB
│ │ │ ├── 1_Tables
│ │ │ │ └── TABLES.sql
│ │ │ ├── 2_Sequences
│ │ │ │ └── SEQUENCES.sql
│ │ │ └── 3_Procedures
│ │ │ │ ├── SP_ADD_CONSUMER_REQUEST_TOKEN.prc
│ │ │ │ ├── SP_ADD_LOG.prc
│ │ │ │ ├── SP_ADD_SERVER_TOKEN.prc
│ │ │ │ ├── SP_AUTH_CONSUMER_REQ_TOKEN.prc
│ │ │ │ ├── SP_CHECK_SERVER_NONCE.prc
│ │ │ │ ├── SP_CONSUMER_STATIC_SAVE.prc
│ │ │ │ ├── SP_COUNT_CONSUMER_ACCESS_TOKEN.prc
│ │ │ │ ├── SP_COUNT_SERVICE_TOKENS.prc
│ │ │ │ ├── SP_DELETE_CONSUMER.prc
│ │ │ │ ├── SP_DELETE_SERVER.prc
│ │ │ │ ├── SP_DELETE_SERVER_TOKEN.prc
│ │ │ │ ├── SP_DEL_CONSUMER_ACCESS_TOKEN.prc
│ │ │ │ ├── SP_DEL_CONSUMER_REQUEST_TOKEN.prc
│ │ │ │ ├── SP_EXCH_CONS_REQ_FOR_ACC_TOKEN.prc
│ │ │ │ ├── SP_GET_CONSUMER.prc
│ │ │ │ ├── SP_GET_CONSUMER_ACCESS_TOKEN.prc
│ │ │ │ ├── SP_GET_CONSUMER_REQUEST_TOKEN.prc
│ │ │ │ ├── SP_GET_CONSUMER_STATIC_SELECT.prc
│ │ │ │ ├── SP_GET_SECRETS_FOR_SIGNATURE.prc
│ │ │ │ ├── SP_GET_SECRETS_FOR_VERIFY.prc
│ │ │ │ ├── SP_GET_SERVER.prc
│ │ │ │ ├── SP_GET_SERVER_FOR_URI.prc
│ │ │ │ ├── SP_GET_SERVER_TOKEN.prc
│ │ │ │ ├── SP_GET_SERVER_TOKEN_SECRETS.prc
│ │ │ │ ├── SP_LIST_CONSUMERS.prc
│ │ │ │ ├── SP_LIST_CONSUMER_TOKENS.prc
│ │ │ │ ├── SP_LIST_LOG.prc
│ │ │ │ ├── SP_LIST_SERVERS.prc
│ │ │ │ ├── SP_LIST_SERVER_TOKENS.prc
│ │ │ │ ├── SP_SET_CONSUMER_ACC_TOKEN_TTL.prc
│ │ │ │ ├── SP_SET_SERVER_TOKEN_TTL.prc
│ │ │ │ ├── SP_UPDATE_CONSUMER.prc
│ │ │ │ └── SP_UPDATE_SERVER.prc
│ │ └── install.php
│ │ └── postgresql
│ │ └── pgsql.sql
│ └── test
│ ├── discovery
│ ├── xrds-fireeagle.xrds
│ ├── xrds-getsatisfaction.xrds
│ └── xrds-magnolia.xrds
│ └── oauth_test.php
└── test.php
/CHANGELOG:
--------------------------------------------------------------------------------
1 | === 1.0.0 2013-02-12
2 |
3 | * First version of the Products API bindings
4 |
5 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License
2 |
3 | Copyright (c) 2013 Semantics3
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
22 |
--------------------------------------------------------------------------------
/VERSION:
--------------------------------------------------------------------------------
1 | 1.0.0
--------------------------------------------------------------------------------
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "semantics3/semantics3-php",
3 | "description": "PHP library bindings for the Semantics3 APIs",
4 | "keywords": [
5 | "semantics3",
6 | "products data",
7 | "api"
8 | ],
9 | "homepage": "https://www.semantics3.com/",
10 | "license": "MIT",
11 | "authors": [
12 | {
13 | "name": "Semantics3 and contributors",
14 | "homepage": "https://github.com/semantics3/semantics3-php/contributors"
15 | }
16 | ],
17 | "require": {
18 | "php": ">=5.4"
19 | },
20 | "autoload": {
21 | "classmap": ["lib/Semantics3/"]
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/lib/Semantics3.php:
--------------------------------------------------------------------------------
1 | apiKey = $apiKey;
10 | $this->apiSecret = $apiSecret;
11 | $this->apiBase = is_null($apiBase) ? "https://api.semantics3.com/v1/" : $apiBase;
12 | }
13 |
14 | public function run_query($endpoint, $params, $method="GET", array $requestOptions = [])
15 | {
16 | if (!$this->apiKey)
17 | throw new Semantics3_AuthenticationError('No API key provided.');
18 |
19 | if (!$this->apiSecret)
20 | throw new Semantics3_AuthenticationError('No API secret provided.');
21 |
22 | $options = array( 'consumer_key' => $this->apiKey, 'consumer_secret' => $this->apiSecret );
23 | OAuthStore::instance("2Leg", $options );
24 | $url = $this->apiBase.$endpoint;
25 | if ($method == "GET") {
26 | $url = $url."?q=".urlencode(json_encode($params));
27 | }
28 | else {
29 | $params = json_encode($params);
30 | }
31 |
32 | try
33 | {
34 | switch ($method) {
35 | case "GET":
36 | $request = new OAuthRequester($url, $method);
37 | break;
38 | case "POST":
39 | $request = new OAuthRequester($url, $method, '', $params);
40 | break;
41 | case "DELETE":
42 | $request = new OAuthRequester($url, $method);
43 | break;
44 | default:
45 | $request = new OAuthRequester($url, $method);
46 | }
47 |
48 | $usrId = array_key_exists('usrId', $requestOptions) ? $requestOptions['usrId'] : 0;
49 | $curlOptions = array_key_exists('curlOptions', $requestOptions) ? $requestOptions['curlOptions'] : [];
50 | $options = array_key_exists('options', $requestOptions) ? $requestOptions['options'] : [];
51 |
52 | $result = $request->doRequest($usrId, $curlOptions, $options);
53 | return $result['body'];
54 | }
55 | catch(OAuthException2 $e)
56 | {
57 | print "\n";
58 | $error = $e->getMessage();
59 | print $error."\n";
60 | }
61 |
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/lib/Semantics3/AuthenticationError.php:
--------------------------------------------------------------------------------
1 | http_status = $http_status;
9 | $this->http_body = $http_body;
10 | $this->json_body = $json_body;
11 | }
12 |
13 | public function getHttpStatus()
14 | {
15 | return $this->http_status;
16 | }
17 |
18 | public function getHttpBody()
19 | {
20 | return $this->http_body;
21 | }
22 |
23 | public function getJsonBody()
24 | {
25 | return $this->json_body;
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/lib/Semantics3/ParameterError.php:
--------------------------------------------------------------------------------
1 | _data_query)){
48 | $this->_data_query[$endpoint] = array();
49 | }
50 | $this->_data_query[$endpoint] = array_merge_recursive((array)$this->_data_query[$endpoint], call_user_func_array("self::_nest_arguments", $args) );
51 |
52 | }
53 |
54 | public function remove(){
55 | $args = func_get_args();
56 | $endpoint = array_shift($args);
57 |
58 | $query = &$this->_data_query[$endpoint];
59 |
60 | foreach ($args as $value){
61 | if (array_key_exists($value,(array)$query)){
62 | if (end($args) == $value){
63 | unset($query[$value]);
64 | }
65 | else
66 | $query = &$query[$value];
67 | }
68 | else {
69 | throw new Semantics3_ParameterError("Attempted to detele something which didn't exist.");
70 | }
71 | }
72 | }
73 |
74 | /**
75 | * get the categories from the API
76 | *
77 | * This function calls the API and returns the categories based on the query
78 | */
79 | public function get_categories(){
80 | $this->_query_result = parent::run_query("categories",$this->_data_query["categories"]);
81 | return $this->_query_result;
82 | }
83 |
84 | public function get_offers(){
85 | $this->_query_result = parent::run_query("offers",$this->_data_query["offers"]);
86 | return $this->_query_result;
87 | }
88 |
89 | private function _nest_arguments(){
90 | $args = func_get_args();
91 |
92 | $query_key = $args[0];
93 | if (count($args) == 2){
94 | $query[$query_key] = $args[1];
95 | }
96 | else if (count($args) > 2) {
97 | unset($args[0]);
98 | $args = array_values($args);
99 | $query[$query_key] = call_user_func_array("self::_nest_arguments", $args);
100 | }
101 |
102 | return $query;
103 | }
104 |
105 | /**
106 | * set the sitedetails fields
107 | *
108 | * This function sets the sitedetails fields
109 | */
110 | public function sitedetails(){
111 | $args = func_get_args();
112 | array_unshift($args, "sitedetails");
113 |
114 | call_user_func_array("self::products_field", $args);
115 | }
116 |
117 | /**
118 | * set the latestoffers fields
119 | *
120 | * This function sets the latestoffers fields
121 | */
122 | public function latestoffers($field_name, $field_value1, $field_value2){
123 | $args = array("sitedetails", $field_name, $field_value1, $field_value2);
124 |
125 | call_user_func_array("self::products_field", $args);
126 | }
127 |
128 | public function limit($limit){
129 | $args = array("limit", $limit);
130 |
131 | call_user_func_array("self::products_field", $args);
132 | }
133 |
134 | public function offset($offset){
135 | $args = array("offset", $offset);
136 |
137 | call_user_func_array("self::products_field", $args);
138 | }
139 |
140 | public function sort_list($sort_field, $sort_value){
141 | $args = array("sort", $sort_field, $sort_value);
142 |
143 | call_user_func_array("self::products_field", $args);
144 | }
145 |
146 | private function _get_products_field(){
147 | # Throw exception if no product field
148 | return json_encode($this->_data_query["products"]);
149 | }
150 |
151 | public function clear_query(){
152 | $this->_data_query = array();
153 | $this->_query_result = array();
154 | }
155 |
156 | public function iterate_products(){
157 | if (gettype($this->_query_result) == "string"){
158 | $query_result = json_decode($this->_query_result, true);
159 | if (!array_key_exists('total_results_count', $query_result) || (array_key_exists('offset', $query_result) && $query_result['offset'] >= $query_result['total_results_count']))
160 | return 0;
161 |
162 | $limit = 10;
163 |
164 | if (array_key_exists('limit', $this->_data_query["products"]))
165 | $limit = $this->_data_query["products"]['limit'];
166 |
167 | if (!array_key_exists('offset', $query_result))
168 | $this->_data_query["products"]['offset'] = 0;
169 | else
170 | $this->_data_query["products"]['offset'] = $query_result['offset'];
171 |
172 | $this->_data_query["products"]['offset'] += $limit;
173 | }
174 | return $this->get_products();
175 | }
176 |
177 | public function all_products(){
178 | $query_result = json_decode($this->_query_result, true);
179 | return array_key_exists('results', $query_result) ? $query_result['results'] : 0;
180 | }
181 |
182 | public function query_json($endpoint, $query_json){
183 | $this->_query_result = parent::run_query($endpoint,json_decode($query_json));
184 | return $this->_query_result;
185 | }
186 |
187 | public function get_query_json($endpoint = null){
188 | if ($endpoint == null){
189 | throw new Semantics3_ParameterError("Query Endpoint was not defined. You need to provide one. Eg: products");
190 | }
191 | return json_encode($this->_data_query[$endpoint]);
192 | }
193 |
194 | public function get_query($endpoint = null){
195 | if ($endpoint == null){
196 | throw new Semantics3_ParameterError("Query Endpoint was not defined. You need to provide one. Eg: products");
197 | }
198 | return $this->_data_query[$endpoint];
199 | }
200 |
201 | public function get_products(){
202 | $this->_query_result = parent::run_query("products",$this->_data_query["products"]);
203 | return $this->_query_result;
204 | }
205 |
206 | public function query($endpoint, $query_arr = array()){
207 | $this->_query_result = parent::run_query($endpoint,$query_arr);
208 | return $this->_query_result;
209 | }
210 |
211 | }
212 |
--------------------------------------------------------------------------------
/lib/oauth-php/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License
2 |
3 | Copyright (c) 2007-2009 Mediamatic Lab
4 | Copyright (c) 2010 Corollarium Technologies
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in
14 | all copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | THE SOFTWARE.
--------------------------------------------------------------------------------
/lib/oauth-php/README:
--------------------------------------------------------------------------------
1 | Please see http://code.google.com/p/oauth-php/ for documentation and help.
2 |
--------------------------------------------------------------------------------
/lib/oauth-php/example/client/googledocs.php:
--------------------------------------------------------------------------------
1 | GOOGLE_CONSUMER_KEY,
48 | 'consumer_secret' => GOOGLE_CONSUMER_SECRET,
49 | 'server_uri' => GOOGLE_OAUTH_HOST,
50 | 'request_token_uri' => GOOGLE_REQUEST_TOKEN_URL,
51 | 'authorize_uri' => GOOGLE_AUTHORIZE_URL,
52 | 'access_token_uri' => GOOGLE_ACCESS_TOKEN_URL
53 | );
54 | // Note: do not use "Session" storage in production. Prefer a database
55 | // storage, such as MySQL.
56 | OAuthStore::instance("Session", $options);
57 |
58 | try
59 | {
60 | // STEP 1: If we do not have an OAuth token yet, go get one
61 | if (empty($_GET["oauth_token"]))
62 | {
63 | $getAuthTokenParams = array('scope' =>
64 | 'http://docs.google.com/feeds/',
65 | 'xoauth_displayname' => 'Oauth test',
66 | 'oauth_callback' => 'http://likeorhate.local/google.php');
67 |
68 | // get a request token
69 | $tokenResultParams = OAuthRequester::requestRequestToken(GOOGLE_CONSUMER_KEY, 0, $getAuthTokenParams);
70 |
71 | // redirect to the google authorization page, they will redirect back
72 | header("Location: " . GOOGLE_AUTHORIZE_URL . "?btmpl=mobile&oauth_token=" . $tokenResultParams['token']);
73 | }
74 | else {
75 | // STEP 2: Get an access token
76 | $oauthToken = $_GET["oauth_token"];
77 |
78 | // echo "oauth_verifier = '" . $oauthVerifier . "'
";
79 | $tokenResultParams = $_GET;
80 |
81 | try {
82 | OAuthRequester::requestAccessToken(GOOGLE_CONSUMER_KEY, $oauthToken, 0, 'POST', $_GET);
83 | }
84 | catch (OAuthException2 $e)
85 | {
86 | var_dump($e);
87 | // Something wrong with the oauth_token.
88 | // Could be:
89 | // 1. Was already ok
90 | // 2. We were not authorized
91 | return;
92 | }
93 |
94 | // make the docs requestrequest.
95 | $request = new OAuthRequester("http://docs.google.com/feeds/documents/private/full", 'GET', $tokenResultParams);
96 | $result = $request->doRequest(0);
97 | if ($result['code'] == 200) {
98 | var_dump($result['body']);
99 | }
100 | else {
101 | echo 'Error';
102 | }
103 | }
104 | }
105 | catch(OAuthException2 $e) {
106 | echo "OAuthException: " . $e->getMessage();
107 | var_dump($e);
108 | }
109 | ?>
--------------------------------------------------------------------------------
/lib/oauth-php/example/client/twolegged.php:
--------------------------------------------------------------------------------
1 | $key, 'consumer_secret' => $secret);
44 | OAuthStore::instance("2Leg", $options);
45 |
46 | $method = "GET";
47 | $params = null;
48 |
49 | try
50 | {
51 | // Obtain a request object for the request we want to make
52 | $request = new OAuthRequester($url, $method, $params);
53 |
54 | // Sign the request, perform a curl request and return the results,
55 | // throws OAuthException2 exception on an error
56 | // $result is an array of the form: array ('code'=>int, 'headers'=>array(), 'body'=>string)
57 | $result = $request->doRequest();
58 |
59 | $response = $result['body'];
60 | var_dump($response);
61 | }
62 | catch(OAuthException2 $e)
63 | {
64 | echo "Exception";
65 | }
66 |
67 | ?>
68 |
--------------------------------------------------------------------------------
/lib/oauth-php/example/client/twoleggedtest.php:
--------------------------------------------------------------------------------
1 | $key, 'consumer_secret' => $secret);
45 | OAuthStore::instance("2Leg", $options);
46 |
47 | $method = "GET";
48 | $params = null;
49 |
50 | try
51 | {
52 | // Obtain a request object for the request we want to make
53 | $request = new OAuthRequester($url, $method, $params);
54 |
55 | // Sign the request, perform a curl request and return the results,
56 | // throws OAuthException2 exception on an error
57 | // $result is an array of the form: array ('code'=>int, 'headers'=>array(), 'body'=>string)
58 | $result = $request->doRequest();
59 |
60 | $response = $result['body'];
61 |
62 | if ($response != 'oauth_token=requestkey&oauth_token_secret=requestsecret')
63 | {
64 | echo 'Error! $response ' . $response;
65 | }
66 | else
67 | {
68 | }
69 |
70 |
71 | var_dump($response);
72 | }
73 | catch(OAuthException2 $e)
74 | {
75 | echo "Exception" . $e->getMessage();
76 | }
77 |
78 | ?>
79 |
--------------------------------------------------------------------------------
/lib/oauth-php/example/client/twoleggedtwitter.php:
--------------------------------------------------------------------------------
1 | TWITTER_CONSUMER_KEY, 'consumer_secret' => TWITTER_CONSUMER_SECRET);
49 | OAuthStore::instance("2Leg", $options);
50 |
51 | try
52 | {
53 | // Obtain a request object for the request we want to make
54 | $request = new OAuthRequester(TWITTER_REQUEST_TOKEN_URL, "POST");
55 | $result = $request->doRequest(0);
56 | parse_str($result['body'], $params);
57 |
58 | echo "aa";
59 |
60 | // now make the request.
61 | $request = new OAuthRequester(TWITTER_PUBLIC_TIMELINE_API, 'GET', $params);
62 | $result = $request->doRequest();
63 | }
64 | catch(OAuthException2 $e)
65 | {
66 | echo "Exception" . $e->getMessage();
67 | }
68 |
69 | ?>
--------------------------------------------------------------------------------
/lib/oauth-php/example/server/INSTALL:
--------------------------------------------------------------------------------
1 | In this example I assume that oauth-php lives in /home/john/src/oauth-php
2 |
3 |
4 | 1) Create a virtual host and set the DB_DSN VARIABLE to the DSN of your (mysql) database.
5 |
6 | Example
7 |
8 | ServerAdmin admin@localhost
9 | ServerName hello.local
10 | DocumentRoot /home/john/src/oauth-php/example/server/www
11 |
12 | UseCanonicalName Off
13 | ServerSignature On
14 |
15 | SetEnv DB_DSN mysql://foo:bar@localhost/oauth_example_server_db
16 |
17 |
18 | Options Indexes FollowSymLinks MultiViews
19 | AllowOverride None
20 | Order allow,deny
21 | Allow from all
22 |
23 |
24 | php_value magic_quotes_gpc 0
25 | php_value register_globals 0
26 | php_value session.auto_start 0
27 |
28 |
29 |
30 |
31 |
32 |
33 | 2) Create the database structure for the server:
34 |
35 | # mysql -u foo -p bar -h localhost < /home/john/src/oauth-php/library/store/mysql/mysql.sql
36 |
37 |
38 |
39 | 3) Download and install smarty into the smarty/core/smarty directory:
40 |
41 | # cd /home/john/src/oauth-php/example/server/core
42 | # wget 'http://www.smarty.net/do_download.php?download_file=Smarty-2.6.19.tar.gz'
43 | # tar zxf Smarty-2.6.19.tar.gz
44 | # mv Smarty-2.6.19 smarty
45 |
46 |
47 | 4) That's it! Point your browser to
48 |
49 | http://hello.local/
50 |
51 | To get started.
52 |
53 | Arjan Scherpenisse , July 2008
54 |
--------------------------------------------------------------------------------
/lib/oauth-php/example/server/core/init.php:
--------------------------------------------------------------------------------
1 |
10 | *
11 | *
12 | * The MIT License
13 | *
14 | * Copyright (c) 2007-2008 Mediamatic Lab
15 | *
16 | * Permission is hereby granted, free of charge, to any person obtaining a copy
17 | * of this software and associated documentation files (the "Software"), to deal
18 | * in the Software without restriction, including without limitation the rights
19 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
20 | * copies of the Software, and to permit persons to whom the Software is
21 | * furnished to do so, subject to the following conditions:
22 | *
23 | * The above copyright notice and this permission notice shall be included in
24 | * all copies or substantial portions of the Software.
25 | *
26 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
27 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
28 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
29 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
30 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
31 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
32 | * THE SOFTWARE.
33 | */
34 |
35 |
36 | /*
37 | * Simple 'user management'
38 | */
39 | define ('USERNAME', 'sysadmin');
40 | define ('PASSWORD', 'sysadmin');
41 |
42 |
43 | /*
44 | * Always announce XRDS OAuth discovery
45 | */
46 | header('X-XRDS-Location: http://' . $_SERVER['SERVER_NAME'] . '/services.xrds');
47 |
48 |
49 | /*
50 | * Initialize the database connection
51 | */
52 | $info = parse_url(getenv('DB_DSN'));
53 | ($GLOBALS['db_conn'] = mysql_connect($info['host'], $info['user'], $info['pass'])) || die(mysql_error());
54 | mysql_select_db(basename($info['path']), $GLOBALS['db_conn']) || die(mysql_error());
55 | unset($info);
56 |
57 |
58 | require_once '../../../library/OAuthServer.php';
59 |
60 | /*
61 | * Initialize OAuth store
62 | */
63 | require_once '../../../library/OAuthStore.php';
64 | OAuthStore::instance('MySQL', array('conn' => $GLOBALS['db_conn']));
65 |
66 |
67 | /*
68 | * Session
69 | */
70 | session_start();
71 |
72 |
73 | /*
74 | * Template handling
75 | */
76 | require_once 'smarty/libs/Smarty.class.php';
77 | function session_smarty()
78 | {
79 | if (!isset($GLOBALS['smarty']))
80 | {
81 | $GLOBALS['smarty'] = new Smarty;
82 | $GLOBALS['smarty']->template_dir = dirname(__FILE__) . '/templates/';
83 | $GLOBALS['smarty']->compile_dir = dirname(__FILE__) . '/../cache/templates_c';
84 | }
85 |
86 | return $GLOBALS['smarty'];
87 | }
88 |
89 | function assert_logged_in()
90 | {
91 | if (empty($_SESSION['authorized']))
92 | {
93 | $uri = $_SERVER['REQUEST_URI'];
94 | header('Location: /logon?goto=' . urlencode($uri));
95 | exit();
96 | }
97 | }
98 |
99 | function assert_request_vars()
100 | {
101 | foreach(func_get_args() as $a)
102 | {
103 | if (!isset($_REQUEST[$a]))
104 | {
105 | header('HTTP/1.1 400 Bad Request');
106 | echo 'Bad request.';
107 | exit;
108 | }
109 | }
110 | }
111 |
112 | function assert_request_vars_all()
113 | {
114 | foreach($_REQUEST as $row)
115 | {
116 | foreach(func_get_args() as $a)
117 | {
118 | if (!isset($row[$a]))
119 | {
120 | header('HTTP/1.1 400 Bad Request');
121 | echo 'Bad request.';
122 | exit;
123 | }
124 | }
125 | }
126 | }
127 |
128 | ?>
--------------------------------------------------------------------------------
/lib/oauth-php/example/server/core/templates/inc/footer.tpl:
--------------------------------------------------------------------------------
1 |