Created
March 23, 2012 20:18
-
-
Save teuneboon/2174558 to your computer and use it in GitHub Desktop.
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 | |
| $config = dirname(__FILE__) . '/library/config.php'; // this config contains things like tokens and what providers are enabled | |
| require_once './library/Hybrid/Auth.php'; | |
| try { | |
| $hybridauth = new Hybrid_Auth($config); | |
| /* | |
| * When the user is not authenticated this redirects that user to the twitter authentication page. | |
| * Twitter then sends the user back to this page | |
| * If the user is already authenticated it simply goes on to the next line of code. | |
| */ | |
| $provider = $hybridauth->authenticate('Twitter'); | |
| $user_profile = $provider->getUserProfile(); // getUserProfile() is available for every "provider" and contains basic information like the displayName and where allowed by the user: the e-mail address | |
| echo 'Hi there! ' . $user_profile->displayName; | |
| $provider->setUserStatus('Hello world!'); // This is an example of API-access, this specific function(getUserStatus()) is available in more providers | |
| $account_totals = $provider->api()->get('account/totals.json'); // You can also directly call the api of a provider by using $provider->api() | |
| $user_contacts = $provider->getUserContacts(); // getUserContacts() is available in most providers, and does what it says: it gets the users friends/contacts | |
| } catch(Exception $e) { | |
| echo 'Ooops, we got an error: ' . $e->getMessage(); | |
| } | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment