本文整理汇总了PHP中Rest::post方法的典型用法代码示例。如果您正苦于以下问题:PHP Rest::post方法的具体用法?PHP Rest::post怎么用?PHP Rest::post使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rest
的用法示例。
在下文中一共展示了Rest::post方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: oAuthRefreshToken
public static function oAuthRefreshToken($user = array(), $updateSession = false, $force = false)
{
$expires = time() + 1000;
if (isset($user['credentials']['expires_at'])) {
$expires = strtotime($user['credentials']['expires_at']);
}
if ($expires < time() || $force) {
$payload = array('client_id' => OAUTH_CLIENT_ID, 'client_secret' => OAUTH_CLIENT_SECRET, 'grant_type' => 'refresh_token', 'refresh_token' => $user['credentials']['refresh_token']);
$refreshedToken = Rest::post('https://accounts.google.com/o/oauth2/token', $payload);
if ($refreshedToken) {
// Credentials
$credentials = UsersCredentialsModel::first(array('user_id' => $user['username']['id']));
$credentials->access_token = $refreshedToken['access_token'];
$credentials->token_type = $refreshedToken['token_type'];
$credentials->expires_at = date(DATE_TIME, time() + $refreshedToken['expires_in']);
$credentials->save();
// Refresh session data
if ($updateSession) {
$_SESSION['usernames'][$user['username']['id']]['credentials']['access_token'] = $credentials->access_token;
$_SESSION['usernames'][$user['username']['id']]['credentials']['expires_at'] = $credentials->expires_at;
if ($_SESSION['current']['username']['id'] == $user['username']['id']) {
$_SESSION['current'] = $_SESSION['usernames'][$user['username']['id']];
}
}
$user['credentials']['access_token'] = $credentials->access_token;
$user['credentials']['expires_at'] = $credentials->expires_at;
}
return $refreshedToken;
}
return $user;
}
示例2: post
public function post()
{
$req_field = array('user_id' => "", 'calendar_id' => "");
$post = $_POST;
$data = array();
foreach ($req_field as $key => $value) {
if (!empty($post[$key])) {
$data[$key] = $post[$key];
}
}
if (count($data) == count($req_field)) {
$this->_data = $data;
$return = parent::post();
} else {
$return = array();
}
return json_encode($return);
}
示例3: FileManagerApi
<?php
namespace AngularFilemanager\LocalBridge;
/**
* PHP Local filesystem bridge for angular-filemanager
*
* @author Jakub Ďuraš <jakub@duras.me>
* @version 0.1.0
*/
include 'LocalBridge/Response.php';
include 'LocalBridge/Rest.php';
include 'LocalBridge/Translate.php';
include 'LocalBridge/FileManagerApi.php';
//Takes two arguments - base path without last slash (default: '$currentDirectory/../files'); language (default: 'en'); mute_errors (default: true, will call ini_set('display_errors', 0))
$fileManagerApi = new FileManagerApi();
$rest = new Rest();
$rest->post([$fileManagerApi, 'postHandler'])->get([$fileManagerApi, 'getHandler'])->handle();