FaceBook - shivaranjan26/Social-Sdk GitHub Wiki
Here you will see how to use this Facebook component to make your coding easier to read user data and also publish anything you like.
-
Firstly you need to get your app id from facebook developer console. To do that you need to create your app and that will generate your app id.
-
Once you get your app id, add it to your manifest file as shown below under application element,
- Then add the below tags too in your manifest file under application tag,
"keyboard|keyboardHidden|screenLayout|screenSize|orientation"
You are all set to use Facebook SDK in your application now. Now lets walkthrough over the Facebook component.
To use this Social SDK Facebook component,
Initialise the below if you want to use your own interface for all facebook actions. MyFacebook facebook = new MyFacebook(this, (FaceBookCallbacks) this, (FBCustomShareCallbacks) this);
or
Initialise the below if you want to use Facebook interface for all facebook actions. MyFacebook facebook = new MyFacebook(this, (FaceBookCallbacks) this, (FBShareCallbacks) this);
Dont forget to implement FaceBookCallbacks and FBCustomShareCallbacks if you are using custom interface or FaceBookCallbacks and FBShareCallbacks if you are wanting to use facebook interface.
Also override onActivityListener() and add the below line in it, facebook.onFaceBookActivityListener(requestCode, resultCode, data);
Now you are all set to use the Social SDK for Facebook.
List of methods in Social SDK Facebook,
-
loginToFacebook(boolean readOnly) : Use this to login to Facebook. If you want to use to Facebook for Retrieving user data only, Pass true for readOnly. If you want to publish on behalf of the user, Pass false. You will receive the callbacks in your implemented methods for Login.
-
isLoggedIn() : Use this to check if you are already logged in. Returns a boolean object
-
fetchUserInformation() : Call this to get all of the user's information. All these info will get mapped to the static variables in that class.
-
getFamilyInformation() : Call this to get the user's family information. This will map the data to an array. The "~" seperator is used to split between name and relationship with that person. So split the string and map data accordingly.
-
getUserLikedPages() : Call this to get the list of pages that the user has liked. This will map the data to an array. The "~" seperator is used to split between name and website for that page. So split the string and map data accordingly.
-
getTaggedPosts() : Call this to get the list of all posts that the user was tagged in. This will return a JSONObject that has all the posts with the comments, reactions, comments of comments and reactions of those.
-
getUserSharedPosts() : Call this to get the list of all posts that the user has shared. This will return a JSONObject that has all the posts with the comments, reactions, comments of comments and reactions of those.
-
getAlbumPhotosWithoutComments() : Call this to get the list of all albums and their pictures. This will return a JSONObject. Also this will not contain the comments for that album.
-
getAlbumPhotosWithComments() : Call this to get the list of all albums and their pictures and comments. This will return a JSONObject.
-
getCustomJSONObject(String fields) : Call this to if you want to use your own set of fields to extract from user profile. To further understand this, check facebook graph api explorer. This will return a JSONObject.
-
publishLinkToFacebook(String quote, String link, String hashTag) : Call this to publish link. This uses Facebook Interface.
-
publishPhotoToFacebook(Bitmap image, String hashTag) : Call this to publish a photo. This uses Facebook Interface.
-
publishPhotosToFacebook(List images, String hashTag) : Call this to share a bunch of photos(max 6). This uses Facebook interface.
-
publishPhotoWithLinkToFacebook(Bitmap image, String link, String hashTag) : Call this publish a photo with a link in it. This uses Facebook interface.
-
publishVideoToFacebook(Uri uri, String hashTag) : Call this to publish a video. This uses Facebook interface.
-
publishVideoWithLinkToFacebook(Uri uri, String link, String hashTag) : Call this to publish a video with a link in it. This uses Facebook interface.
- shareContentUsingCustomInterface(ShareLinkContent content)
- shareContentUsingCustomInterface(SharePhotoContent content)
- shareContentUsingCustomInterface(ShareMediaContent content)
- shareContentUsingCustomInterface(ShareVideoContent content)
- getShareLinkContent(String quote, String link, String hashTag)
- getSharePhotoContent(Bitmap image, String hashTag)
- getShareMediaContent(List images, String hashTag)
- getSharePhotoContentWithLink(Bitmap image, String link, String hashTag)
- getShareVideoContent(Uri uri, String hashTag)
- getShareVideoContentWithLink(Uri uri, String link, String hashTag)