当前位置: 首页>>代码示例>>PHP>>正文


PHP PSU::api方法代码示例

本文整理汇总了PHP中PSU::api方法的典型用法代码示例。如果您正苦于以下问题:PHP PSU::api方法的具体用法?PHP PSU::api怎么用?PHP PSU::api使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PSU的用法示例。


在下文中一共展示了PSU::api方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: get

 public function get()
 {
     // Load API
     $client = \PSU::api('backend');
     // Get all of the people that work at the helpdesk.
     $users = $client->get('support/users');
     return $users;
 }
开发者ID:AholibamaSI,项目名称:plymouth-webapp,代码行数:8,代码来源:StaffCollection.php

示例2: _get_userdatabylogin

 protected function _get_userdatabylogin($wp_id)
 {
     static $data = null;
     if (null === $data[$wp_id]) {
         $data[$wp_id] = \PSU::api('backend')->get('wp/{{wp_id}}', array('wp_id' => $wp_id));
     }
     //end if
     return $data[$wp_id];
 }
开发者ID:AholibamaSI,项目名称:plymouth-webapp,代码行数:9,代码来源:PSUPerson_Loader_Connect.class.php

示例3: get_results

 /**
  * Public method to get the results of a search query from the Directory API
  * @param string $query A string containing the search query
  */
 public static function get_results($query)
 {
     // Initialize the search results array, in case the API fails
     $search_results = array();
     // PSU::api uses Guzzle for its HTTP responses. We need to catch an exception, in case the call fails
     try {
         // Get the search results with the PSU REST API
         $search_results = (array) \PSU::api('backend')->get('directory/search/' . urlencode($query));
     } catch (Guzzle\Http\Message\BadResponseException $e) {
         // Lets grab the exception and put it into the session
         $_SESSION['errors'][] = $e->getMessage();
         // Let's get the response data so we can see the problem
         $response = $e->getResponse();
         // Let's grab the HTTP status and status code
         $response_data['status'] = $response->getReasonPhrase();
         $response_data['status_code'] = $response->getStatusCode();
     }
     return $search_results;
 }
开发者ID:AholibamaSI,项目名称:plymouth-webapp,代码行数:23,代码来源:Directory.php

示例4: respond

<?php

// Generic response (don't force the trailing slash: this should catch any accidental laziness)
respond('/?', function ($request, $response, $app) {
    // Get the available clusters with the PSU REST API
    $clusters = (array) \PSU::api('backend')->get('clusters');
    // Sort the returned clusters array
    /* This sort's the clusters array by this priority:
     * Number of computer's free
     * Building name
     * Cluster name
     */
    usort($clusters, function ($a, $b) {
        // If the number of computers free are the same
        if ($a->num_computers_free == $b->num_computers_free) {
            // If the buildings are the same
            if ($a->building == $b->building) {
                // If the cluster name is the same
                if ($a->name == $b->name) {
                    // Return 0. They're equal
                    return 0;
                } else {
                    // Return the name in alphabetical order
                    return $a->name < $b->name ? -1 : 1;
                }
                //end else
            } else {
                // Return the name of the building in alphabetical order
                return $a->building < $b->building ? -1 : 1;
            }
            //end else
开发者ID:AholibamaSI,项目名称:plymouth-webapp,代码行数:31,代码来源:clusters.php

示例5: respond

<?php

require_once PSU_EXTERNAL_DIR . '/klein/klein.php';
respond(function ($request, $response, $app) {
    $app->config = PSU\Config\Factory::get_config();
    if (false == $app->config->get('cdn', 'enabled', true)) {
        define('PSU_CDN', false);
    }
    $response->psu_lazyload = function ($ids) use($request, $response, $app) {
        if (!is_array($ids)) {
            $ids = array($ids);
        }
        $qs = http_build_query(array('id' => $ids));
        try {
            $json = \PSU::api('backend')->get("user/?{$qs}");
            $people = $json;
        } catch (Exception $e) {
            // nothing...?
            throw $e;
        }
        $response->header('Content-Type', 'application/json');
        $response->json($people);
    };
});
// Load routes for this hostname
$webapp->host()->routes();
respond('404', function ($request, $response, $app) {
    $response->code(404);
    $response->header('Content-Type', 'text/plain');
    echo '404 Not Found';
    error_log(sprintf("404 %s%s", $_SERVER['HTTP_HOST'], $_SERVER['REQUEST_URI']), E_USER_NOTICE);
开发者ID:AholibamaSI,项目名称:plymouth-webapp,代码行数:31,代码来源:routes.php

示例6: respond

// Generic response (don't force the trailing slash: this should catch any accidental laziness)
respond('/?', function ($request, $response, $app) {
    // Let's create a new person based off of who's logged in
    $person = new \PSUPerson($_SESSION['username']);
    // Let's create an array to hold the schedule data
    $schedule = array();
    // Because this data is lazy loaded, let's just ask for it so that we force the request
    $person->student->levels;
    // Let's go through each level of the student
    foreach ($person->student->levels as $level) {
        // Let's get the current term code for that level
        $term_code = (array) \PSU::api('backend')->get('student/term-code/' . $level);
        // PSU::api uses Guzzle for its HTTP responses. We need to catch an exception, in case the call fails
        try {
            // Now let's add the schedule data for that term into our schedule array
            $schedule[$level] = (array) \PSU::api('backend')->get('student/schedule/{{identifier}}', array('identifier' => $person->id), array('term_code' => $term_code['term_code']));
        } catch (Guzzle\Http\Message\BadResponseException $e) {
            // Lets grab the exception and put it into the session
            $_SESSION['errors'][] = $e->getMessage();
            // Let's get the response data so we can see the problem
            $response = $e->getResponse();
            // Let's grab the HTTP status and status code
            $response_data['status'] = $response->getReasonPhrase();
            $response_data['status_code'] = $response->getStatusCode();
        }
    }
    $app->tpl->assign('schedule', $schedule);
    // Display the template
    $app->tpl->assign('show_page', 'schedule');
    $app->tpl->display('_wrapper.tpl');
});
开发者ID:AholibamaSI,项目名称:plymouth-webapp,代码行数:31,代码来源:schedule.php


注:本文中的PSU::api方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。