-
Notifications
You must be signed in to change notification settings - Fork 8
/
bootstrap.php
71 lines (62 loc) · 2.22 KB
/
bootstrap.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
<?php
// Composer based autoloading (see: http://getcomposer.org/doc/04-schema.md#autoload)
require __DIR__ . '/vendor/autoload.php';
date_default_timezone_set('America/Los_Angeles');
session_start();
use GuzzleHttp\Client;
use GuzzleHttp\Subscriber\Cache\CacheSubscriber;
use Foxy\FoxyClient\FoxyClient;
/******* CONFIGURATION ********/
/**
* If you want to toy around in the sandbox, change this to true.
*/
$config = array(
'use_sandbox' => false
);
/**
* If you have already registered an OAuth client, you can add the client_id and client_secret below and uncomment these lines.
* This will keep your client logged in all the time. Otherwise, you can select the "Authenticate Client" link and add
* your values there to authenticate your client for this session only.
*/
//$config['client_id'] = '';
//$config['client_secret'] = '';
/**
* If you already have an OAuth refresh token, add it below. Keep in mind, each token has a different scope such as
* client_full_accesss (allowing you to modify your OAuth client and create a user)
* user_full_accesss (allowing you to modify your user and create a store)
* store_full_access (allowing you to modify your store and create new stores)
*
* Ideally, for this client example, you want to paste in refresh token that has the store_full_access scope for a store.
*/
//$config['refresh_token'] = '';
/**
* If you happen to have the current access_token and time it has left before needing to be refreshed, you can pass that in also, otherwise a new token will automatically be obtained.
*/
//$config['access_token'] = '';
//$config['access_token_expires'] = '';
$guzzle_config = array(
'defaults' => array(
'debug' => false,
'exceptions' => false
)
);
/**
* Set up our Guzzle Client
*/
$guzzle = new Client($guzzle_config);
CacheSubscriber::attach($guzzle);
/**
* Get our FoxyClient
*/
$fc = new FoxyClient($guzzle, $config);
/**
* Get some Cross Site Request Forgery protection love goin' on.
*/
$csrf = new \Riimu\Kit\CSRF\CSRFHandler(false);
try {
$csrf->validateRequest(true);
} catch (\Riimu\Kit\CSRF\InvalidCSRFTokenException $ex) {
header('HTTP/1.0 400 Bad Request');
exit('Bad CSRF Token!');
}
$token = $csrf->getToken();