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


PHP API::AddHandler方法代码示例

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


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

示例1: curl_setopt

                    }
                }
            }
            if ($ch = curl_init()) {
                curl_setopt($ch, CURLOPT_URL, $url);
                curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
                if ($timeout) {
                    curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
                }
                if ($data) {
                    curl_setopt($ch, CURLOPT_POST, true);
                    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
                }
                $response = curl_exec($ch);
                $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
                if ($binary && $response) {
                    $response = "data:{$mime};base64," . base64_encode($response);
                }
                $result = array("httpCode" => $httpcode, "body" => $response);
                curl_close($ch);
            } else {
                $error = "Failed to initialize cURL";
            }
        }
        return array($error, $result);
    }
}
API::AddHandler('application', array('CoreAPIHandler', 'application'));
API::AddHandler('fs', array('CoreAPIHandler', 'fs'));
API::AddHandler('curl', array('CoreAPIHandler', 'curl'));
开发者ID:osuisumi,项目名称:OS.js,代码行数:30,代码来源:api.php

示例2: login

 * @licence Simplified BSD License
 */
/**
 * This is your handler class
 *
 * Out-of-the-box support for permissions! You just have to make sure your
 * login method returns the right groups.
 *
 * @link http://os.js.org/doc/tutorials/create-handler.html
 */
class EXAMPLEAPIHandler extends APIHandler
{
    public static function login(array $arguments)
    {
        $user = APIUser::login(array("id" => 0, "username" => "test", "name" => "EXAMPLE handler user", "groups" => array("admin")));
        return array(false, $user->getData());
    }
    public static function logout(array $arguments)
    {
        APIUser::logout();
        return array(false, true);
    }
    public static function settings(array $arguments)
    {
        return array(false, true);
    }
}
API::AddHandler('login', array('EXAMPLEAPIHandler', 'login'));
API::AddHandler('logout', array('EXAMPLEAPIHandler', 'logout'));
API::AddHandler('settings', array('EXAMPLEAPIHandler', 'settings'));
API::SetHandler('EXAMPLEAPIHandler');
开发者ID:genecyber,项目名称:OS.js-v2,代码行数:31,代码来源:php.php

示例3: login

 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * @author  Anders Evenrud <andersevenrud@gmail.com>
 * @licence Simplified BSD License
 */
/**
 * DemoAPIHandler for demoing
 */
class DemoAPIHandler extends APIHandler
{
    public static function login(array $arguments)
    {
        $user = APIUser::login(array("id" => 0, "username" => "demo", "name" => "Demo User", "groups" => array("admin")));
        return array(false, $user->getData());
    }
    public static function logout(array $arguments)
    {
        APIUser::logout();
        return array(false, true);
    }
    /**
     * Demo handler allows EVERYTHING
     */
    public static function checkPrivilege($requires = null)
    {
        APIHandler::checkPrivilege(true);
    }
}
API::AddHandler('login', array('DemoAPIHandler', 'login'));
API::AddHandler('logout', array('DemoAPIHandler', 'logout'));
API::SetHandler('DemoAPIHandler');
开发者ID:MicroBlocks,项目名称:OS.js,代码行数:31,代码来源:handler.php

示例4: array

        $db = self::_initDB();
        APIUser::logout();
        return array(false, true);
    }
    public static function settings(array $arguments)
    {
        $db = self::_initDB();
        $result = false;
        if (!isset($_SESSION['user'])) {
            throw new Exception("Cannot set settings without user session");
        }
        $q = "UPDATE `users` SET `settings` = ? WHERE `id` = ?;";
        $a = array(json_encode($arguments['settings']), $_SESSION['user']['id']);
        if ($stmt = $db->prepare($q)) {
            $result = $stmt->execute($a);
        }
        return array(false, $result);
    }
    /**
     * This enables full privileges for all users. Simply remove to make use of the groups
     * @see APIUser
     */
    public static function checkPrivilege($requires = null)
    {
        APIHandler::checkPrivilege(true);
    }
}
API::AddHandler('login', array('ExampleAPIHandler', 'login'));
API::AddHandler('logout', array('ExampleAPIHandler', 'logout'));
API::AddHandler('settings', array('ExampleAPIHandler', 'settings'));
API::SetHandler('ExampleAPIHandler');
开发者ID:AlexanderBrevig,项目名称:OS.js-v2,代码行数:31,代码来源:handler.php

示例5: broadway

<?php

class BroadwayAPIHandler
{
    public static function broadway(array $arguments)
    {
        return array(false, false);
    }
}
API::AddHandler('broadway', array('BroadwayAPIHandler', 'broadway'));
开发者ID:AlexanderBrevig,项目名称:OS.js-v2,代码行数:10,代码来源:api.php


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