Last active
December 18, 2015 23:28
-
-
Save davidhq/5861453 to your computer and use it in GitHub Desktop.
get user id from oauth token for elgg with elgg_social_login
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function get_guid_from_oauth($provider, $token) { | |
global $CONFIG; | |
$identifier = strtolower($provider); | |
foreach (array("LinkedIn", "MySpace", "AOL") as $prov) { | |
$identifier = str_replace(strtolower($prov), $prov, $identifier); | |
} | |
$identifier = ucfirst($identifier) . "_" . $token; | |
$query = "SELECT entity_guid from {$CONFIG->dbprefix}private_settings where name = 'plugin:user_setting:elgg_social_login:uid' and value = '{$identifier}'"; | |
$guid = get_data_row($query)->entity_guid; | |
if($guid) return $guid; else throw new Exception("User with OAuth identifier {$identifier} not found"); | |
} | |
echo get_guid_from_oauth("facebook", "713936190"); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment