<?php

require_once '../StageBloc.php';
require_once 'config.php';
$stagebloc = new Services_StageBloc($clientId, $clientSecret, $redirectUri, $inDevelopment);
if (isset($_GET['code'])) {
    try {
        $accessToken = $stagebloc->accessToken($_GET['code']);
        echo 'Successfully authenticated! Your access token is ' . $accessToken['access_token'] . '<br/>' . '<a href="request.php?accessToken=' . $accessToken['access_token'] . '">Try an example request</a>';
    } catch (Services_StageBloc_Invalid_Http_Response_Code_Exception $e) {
        exit($e->getMessage());
    }
} else {
    $authUrl = $stagebloc->getAuthorizeUrl(array('scope' => 'non-expiring'));
    echo '<a href="' . $authUrl . '">Connect With StageBloc</a>';
}
示例#2
0
<?php

require_once '../StageBloc.php';
require_once 'config.php';
// If sent here from authentication.php, we can grab the access token from there
// Note: You should copy this access token into the info.php file for further testing once you receive it
if (!empty($_GET) && isset($_GET['accessToken'])) {
    $accessToken = $_GET['accessToken'];
}
// Setup our StageBloc OAuth object
$stagebloc = new Services_StageBloc($clientId, $clientSecret, $redirectUri, $inDevelopment);
$stagebloc->setAccessToken($accessToken);
$stagebloc->setResponseFormat('json');
// XML is default, JSON is also accepted
// Post a test status update
// Warning: This will update your StageBloc account with test data! Comment this out if you don't want that to happen!
$postData = array('text' => 'Status update from StageBloc\'s PHP API wrapper!');
$test = $stagebloc->post('statuses/edit', $postData);
// Get the statuses for this account
$items = $stagebloc->get('statuses/list');
echo '<h2>Statuses</h2>';
// If the response format is XML, it might be easier to understand the output by viewing the page source
echo $items;
// Using {Include file="<theme_file_name>.sbt"} anywhere in your main theme.sbt file will include theme_file_name.sbt from this folder
// This can be used as a way to organize your theme a bit more and not have to have all the HTML in one file
// If null, it'll assume your entire theme is in theme.sbt
$themeViewsPath = null;
// The path to where CSS files are stored for each theme relative to the theme itself (i.e. you shouldn't need a beginning slash)
// Each CSS file in the folder specified by the path will be added in a <link> tag at the top of the theme (folder searching isn't recursive)
// If you use "Submit" theme, the CSS from the files in this directory will be appended into one, larger CSS dump before POSTing it to the server
// If null, it will look for /theme_dir/style.css
$cssPath = null;
// The path to where JS files are stored for each theme relative to the theme itself (i.e. you shouldn't need a beginning slash)
// Behaves similarily to $cssPath with regards to the other behaviors
// If null, it will look for /theme_dir/javascript.js
$jsPath = null;
// Once you have the other three pieces of information, this can be found by using index.php to get an access token
// It will be placed here for you automatically once you login with your StageBloc credentials
$accessToken = null;
// This will be populated for your automagically upon authentication
// For those who are curious, it's basically just a log of the JSON returned from the API to have locally
// So if you ever need to "reset" your login, changing both this and $accessToken back to null will force another login
$accountData = null;
// Since you're authenticated with the API, the theming engine usually assumes there's a logged in user when rendering the theme
// Set this to true to simulate what a logged out user would see (useful when testing fan club stuff, etc)
$simulateLoggedOutUser = false;
$inDevelopment = false;
// This will basically always be false, StageBloc uses this internally
// These files should not be included in the page or submitted to the theme
$jsFileBlacklist = ['gulpfile.js', 'Gruntfile.js'];
// Setup our StageBloc OAuth object
$stagebloc = new Services_StageBloc($clientId, $clientSecret, $redirectUri, $inDevelopment);
$stagebloc->setAccessToken($accessToken);
$stagebloc->setResponseFormat('json');