Esempio n. 1
0
/**
 * @brief GG_VerifyIDToken
 * 防止第三方截包
 *
 * @param $idToken
 *
 * @return if ok return user_id and email
 */
function GG_VerifyIDToken($idToken)
{
    $url = "https://www.googleapis.com/oauth2/v1/tokeninfo";
    $params = array("id_token" => $idToken);
    $data = X_GET($url, $params);
    $r = json_decode($data, true);
    $data = array();
    $data['user_id'] = $r['user_id'];
    $data['name'] = $r['email'];
    $data['email'] = $r['email'];
    return $data;
}
Esempio n. 2
0
/**
 * @brief FB_GetUser
 *
 * @param $userId
 * @param $token
 *
 * @return
 */
function FB_GetUser($userId, $token)
{
    $url = "https://graph.facebook.com/";
    $url = sprintf("%s%s", $url, $userId);
    $params = array("access_token" => $token);
    $data = X_GET($url, $params);
    $r = json_decode($data, true);
    return $r;
}
Esempio n. 3
0
/**
 * @brief YH_GetUser
 *
 * about realm
 * http://oauth.net/core/1.0 5.4, 9.1
 *
 * @param $guid
 * @param $accessToken
 * @param $accessTokenSecret
 *
 * @return
 */
function YH_GetUser($guid, $accessToken, $accessTokenSecret)
{
    $url = sprintf("http://social.yahooapis.com/v1/user/%s/profile", $guid);
    $nonce = md5(mt_rand());
    $timestamp = time();
    $params = array("oauth_consumer_key" => YAHOO_CONSUMER_KEY, "oauth_nonce" => $nonce, "oauth_signature_method" => "HMAC-SHA1", "oauth_timestamp" => $timestamp, "oauth_version" => "1.0", "oauth_token" => $accessToken, "format" => "json");
    $b = YH_MakeSignatureBaseString("GET", $url, $params);
    $key = YAHOO_CONSUMER_SECRET . '&' . $accessTokenSecret;
    $s = YH_Signature($b, $key);
    $params['oauth_signature'] = $s;
    $data = X_GET($url, $params);
    $r = json_decode($data, true);
    $data = array();
    $data['user_id'] = $r['profile']['guid'];
    $data['name'] = sprintf("%s %s", $r['profile']['givenName'], $r['profile']['familyName']);
    foreach ($r['profile']['emails'] as $v) {
        if (array_key_exists("primary", $v) && $v['primary'] == 1) {
            $data['email'] = $v['handle'];
            break;
        }
    }
    return $data;
}