コード例 #1
0
 public function PrintOuput(ApiHandler $api)
 {
     $this->SetHeaderContentType();
     try {
         $val = $api->ExecuteApi();
     } catch (ApiException $e) {
         // If something goes wrong, set the proper header
         $temp_arr = $e->getArrayMessage();
         header($temp_arr["header"]);
         // Ouput the error JSONized without the header info
         unset($temp_arr["header"]);
         die($this->FormatOuput($temp_arr));
     }
     echo $this->FormatOuput($val);
 }
コード例 #2
0
ファイル: BaseController.php プロジェクト: simmatrix/MMUCRS
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     $item = \ApiHandler::parseSingle($this->model, $id)->getResult();
     return \Fractal::item($item, $this->transformer)->getArray();
 }
コード例 #3
0
ファイル: aaa.php プロジェクト: ram-1501/rs
<?php

// echo phpversion();
// echo "<br>";
// header('Content-Type: text/plain');
// require_once('settings.inc');
require_once 'modules/api_handler.inc';
require_once 'modules/GoogleAPI.php';
require_once 'twitteroauth/twitteroauth.php';
require_once 'twitteroauth/config.php';
require_once dirname(__DIR__) . '/vendor/recurly_lib/recurly.php';
require_once 'modules/simple_html_dom.php';
Recurly_Client::$subdomain = RECURLY_SUB_DOMAIN;
Recurly_Client::$apiKey = RECURLY_API_KEY;
$api = new ApiHandler();
// Try to setup our session
// Utilities::eClincherSetupUserSession();
// For analytics/backtracing
$bt = debug_backtrace();
$log_response_to_ec_error_handler = false;
array_shift($bt);
$ajax_time_started = microtime(TRUE);
$ajax_label = 'Unknown';
if ($log_response_to_ec_error_handler) {
    ob_start();
}
// Detect and respond to our users that we're in maintenance mode > 1
if (ECConfig::get('MAINTENANCE_MODE') > 1) {
    // echo "Reload page";
    echo file_get_contents(ROOT_PATH . '/web/maintenance.html');
    exit;
コード例 #4
0
ファイル: User.php プロジェクト: nbar1/gs
 /**
  * Register User
  *
  * @param string $username
  * @param string $password
  * @return status
  */
 public function registerUser($username, $password)
 {
     $username = trim($username);
     if ($this->getDao()->getUserExistsByUsername($username)) {
         ApiHandler::sendResponse(200, array('error' => true, 'message' => 'User already exists'));
         return USER_ALREADY_EXISTS;
     }
     $password = md5($password);
     $created = date('Y-m-d H:i:s');
     $api_key = md5($username . $created);
     return $this->getDao()->createUser(array($username, $password, $api_key, $created, $created));
 }
コード例 #5
0
 /**
  * If this a valid route?
  *
  * @param $route
  *
  * @return bool
  */
 public static function ValidRoute($route)
 {
     return ApiHandler::GetName($route) != false ? true : false;
 }
コード例 #6
0
ファイル: routes.php プロジェクト: nbar1/gs
$app->get('/api/v1/player/next', function () {
    $player = new Player();
    $song = $player->playNextSong();
    if ($song !== false) {
        ApiHandler::sendResponse(200, true, array('token' => $song));
    } else {
        ApiHandler::sendResponse(200, false);
    }
});
/**
 * Gets the stream token for a given song
 */
$app->get('/api/v1/player/stream/:token', function ($token) {
    $player = new Player();
    ApiHandler::sendResponse(200, true, $player->getStream($token));
});
/**
 * Validates the song is playing with GrooveShark after 30 seconds
 */
$app->post('/api/v1/player/stream/validate', function () {
    $player = new Player();
    $player->markSong30Seconds($_POST['streamKey'], $_POST['streamServerID']);
    ApiHandler::sendResponse(200, true);
});
/**
 * Marks a song as played
 */
$app->post('/api/v1/song/:id/played', function ($id) use($base) {
    $player = new Player();
    echo ApiHandler::sendResponse(200, $player->markSongComplete($id));
});