本文整理汇总了PHP中HttpClient::getData方法的典型用法代码示例。如果您正苦于以下问题:PHP HttpClient::getData方法的具体用法?PHP HttpClient::getData怎么用?PHP HttpClient::getData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HttpClient
的用法示例。
在下文中一共展示了HttpClient::getData方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
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;
}
// -------------------------------------------------------------------------------------------
?>
<h1>Hi, <?php
echo $responseArray['user']['name'];
?>
</h1>
<img src='<?php
echo $responseArray['user']['avatar_url'];
?>
示例2: getData
private function getData($url)
{
$httpClient = new HttpClient();
return $httpClient->getData($url);
}