本文整理汇总了PHP中HttpClient::readCookie方法的典型用法代码示例。如果您正苦于以下问题:PHP HttpClient::readCookie方法的具体用法?PHP HttpClient::readCookie怎么用?PHP HttpClient::readCookie使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HttpClient
的用法示例。
在下文中一共展示了HttpClient::readCookie方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: HttpClient
error_reporting(E_ALL);
// debug
// TODO: obviously this is just a demo -- needs to be seperated into a new class, etc...
session_start();
require_once 'config.php';
require_once 'http_client.class.php';
try {
$httpClient = new HttpClient();
// --------------{{ CHECK FOR TOKEN
if (isset($_SESSION) && !empty($_SESSION['access_token'])) {
// *** new session started -- cache session to local file (prevents needing to reauthorize your app)
$accessToken = $_SESSION['access_token'];
$httpClient->createCookie($_SESSION['access_token']);
} else {
// *** session has expired -- load our cached access_token from a local file
$accessToken = $httpClient->readCookie();
if (empty($accessToken)) {
// no access token found!
$httpClient->redirectToLoginPage();
}
}
// ----------------}}
$headers = array('Authorization: Bearer ' . $accessToken);
// required auth2 header
$response = $httpClient->getData($apiConfig['userprofileUrlBase'], $headers);
$responseArray = json_decode($response, TRUE);
} catch (Exception $e) {
echo '*** Error: exception ' . $e->getMessage();
//$httpClient->redirectToLoginPage();
exit;
}