本文整理汇总了PHP中Lib::doRequest方法的典型用法代码示例。如果您正苦于以下问题:PHP Lib::doRequest方法的具体用法?PHP Lib::doRequest怎么用?PHP Lib::doRequest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Lib
的用法示例。
在下文中一共展示了Lib::doRequest方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getUserInfo
public function getUserInfo($code)
{
// Exchange token
$result = Lib::doPostForm('https://accounts.google.com/o/oauth2/token', array(), array('code' => $_GET['code'], 'redirect_uri' => $this->config['redirect_uri'], 'client_id' => $this->config['client_id'], 'scope' => $scopes, 'client_secret' => $this->config['client_secret'], 'grant_type' => 'authorization_code'));
if (null == $result) {
return null;
}
$tokens = json_decode($result, true);
// Get User Info
$result = Lib::doRequest('GET', 'https://www.googleapis.com/oauth2/v2/userinfo', array('Authorization: ' . $tokens['token_type'] . ' ' . $tokens['access_token']), array());
if (null == $result) {
return null;
}
return json_decode($result, true);
}
示例2: getUserInfo
public function getUserInfo($code)
{
// Exchange token
$result = Lib::doRequest('GET', 'https://graph.facebook.com/oauth/access_token?' . 'client_id=' . urlencode($this->config['app_id']) . '&client_secret=' . urlencode($this->config['app_secret']) . '&redirect_uri=' . urlencode($this->config['redirect_uri']) . '&code=' . urlencode($code), array(), array());
if (null == $result) {
return null;
}
$tokens = array();
parse_str($result, $tokens);
// Get User Info
$result = Lib::doRequest('GET', 'https://graph.facebook.com/me?' . 'access_token=' . urlencode($tokens['access_token']), array(), array());
if (null == $result) {
return null;
}
$user_info = json_decode($result, true);
if (!in_array(array('id', 'email', 'name'), $user_info)) {
return null;
}
$user_info['picture'] = "http://graph.facebook.com/{$user_info['id']}/picture";
return $user_info;
}
示例3: doPostForm
public static function doPostForm($url, $headers, $body)
{
$headers[] = 'Content-type: application/x-www-form-urlencoded';
$headers = array_unique($headers);
return Lib::doRequest('POST', $url, $headers, http_build_query($body));
}