Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
foxyclient-php-example/bootstrap.php
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
71 lines (62 sloc)
2.22 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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(); |