Errors and Exceptions Handling
Since 2.0 HybridAuth work mostly on exceptions, just throw your code inside an try{} catch(Exception $e){}
block and that is it.
HybridAuth errors codes
Error Code | Description |
0 | Unspecified error |
1 | Hybriauth configuration error |
2 | Provider not properly configured |
3 | Unknown or disabled provider |
4 | Missing provider application credentials (your application id, key or secret) |
5 | Authentification failed |
6 | User profile request failed |
7 | User not connected to the provider |
8 | Provider does not support this feature |
Example: Try to grab the profile of a disconnected user
# authenticate with twitter $twitter = $hybridauth->authenticate( "Twitter" ); # to log out from twitter first $twitter->logout(); try{ # then try to grab the user profile $user_profile = $twitter->getUserProfile(); } catch( Exception $e ){ echo "Ooophs, we got an error: " . $e->getMessage(); echo " Error code: " . $e->getCode(); }
This shoul dispaly a error like this one:
Ooophs, we got an error: User profile request failed! User not connected to Twitter. Error code: 6