SocialAuth Android is an Android version of popular SocialAuth Java library. Now you do not need to integrate multiple SDKs if you want to integrate your application with multiple social networks. You just need to add few lines of code after integrating the SocialAuth Android library in your app.
The API enables user authentication and sharing updates through different various social networks and hides all the intricacies of generating signatures & token, doing security handshakes and provide an easy mechanism to build cool social apps.
With this library, you can:
- Quickly build share functionality for posting updates on facebook, twitter, linkedin and more
- Easily create a Share button or a social bar containing various social networks
- Access profile of logged in user for easy user registration
- Import friend contacts of logged in user (Email, Profile URL and Name)
- Do much more using our flexible API like extend it for more network
A) Installation :
1. Créez votre projet android
2. Téléchargez à l’adresse https://sourceforge.net/projects/socialauth-android/?source=typ_redirect le sdk
3. Importez le fichier the socialauth-4.9.jar (à télécharger ici) et socialauth-android-3.2 (situé dans le répertoire dist) dans votre projet :
In the project right click
-> new -> module
-> import jar/AAR package
-> import select the jar file to import
-> click ok -> done
4. Créez un répertoire « assets » File > New > folder > assets Folder et copiez le fichier oauth_consumer.properties contenu dans le répertoire « assets » du sdk
6. Modifiez le fichier manifest en ajoutant :
<uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
B) Exemple de mise en oeuvre :
- Récupérez toutes les clefs pour accéder aux réseaux sociaux désirés :
- Google (show screenshot) – http://code.google.com/apis/accounts/docs/RegistrationForWebAppsAuto.html
- Yahoo (show screenshot) – https://developer.apps.yahoo.com/dashboard/createKey.html
- Twitter – http://twitter.com/apps
- Facebook – http://www.facebook.com/developers/apps.php
- Hotmail (show screenshot) – http://msdn.microsoft.com/en-us/library/cc287659.aspx
- FourSquare – (show screenshot) – https://foursquare.com/oauth/
- MySpace – (show screenshot) – http://developer.myspace.com/Apps.mvc
- Linkedin – (show screenshot) – https://www.linkedin.com/secure/developer
- Salesforce – (show screenshot)
- Yammer – (show screenshot) – https://www.yammer.com/client_applications
- Mendeley – (show screenshot) – http://dev.mendeley.com/applications/register/
- Flickr – http://www.flickr.com/services/apps2. Editez le fichier « oauth_consumer.properties » afin de placer vos clefs
Pour twitter, « Request email addresses from users » doit être coché dans l’onglet « permissions »
C) Connexion directe à FaceBook :
Créez une application android vide.
A la page https://developers.facebook.com/ créez une application et récupérez son id.
Dans votre application android ajouter l’id dans values/strings.xml :
<string name="facebook_app_id">xxxxxxxxxxxxxxxx</string>
Dans paramètres de votre application Facebook cliquez sur ajouter une plateforme et Android
Copiez le nom du package de votre application android (à lire dans le manifest) (exemple com.andrologiciels.monapp
Et dans le nom de la classe le nom de votre main activity précédé du nom du package (exemple com.andrologiciels.monapp.MainActivity)
Pour Hachages clés, allez dans l’onglet « gradle » en haut à droite verticalement dans studio, rafraichissez et cliquez sur app/android/signing report en bas à droite cliquez sur gradle console et récupérez la clef SHA1. Enregistrez les modification et cliquez sur utilisez ce nom de package.
Allez à la page https://developers.facebook.com/docs/facebook-login/android et suivez les instructions « avec MAVEN » (modifiez les « depentecies »)
Références :
http://www.theappguruz.com/blog/android-twitter-integration-tutorial
Pour recevoir des données en provenance d’autres applications :
https://developer.android.com/training/sharing/receive.html
Pour la connexion avec FaceBook :