This repository contains a collection of Java libraries which can be used to fetch data from popular social networks like Facebook, Instagram and LinkedIn. There is a separate repository of mine to fetch data from Twitter.
The libraries I am releasing in this repo are for educational and research purposes only. I have not provided the JAR files. You will have to build it yourself. Also, this repo is NOT affiliated to Facebook, Instagram and LinkedIn. This is my personal research project.
This repo shows different ways with which data can be fetched from an internet service. Official public API is not the only way. Data can be fetched by easily scraping the legacy sites (so that we'll get plain old HTML pages without any JavaScript jargon). Data can also be fetched by using the private APIs, i.e., the API which are meant to be accessed by the Android/iOS apps. By emulating an Android/iOS device through our code, we can easily hit requests to the private API and that spits out the data.
There are many Python libraries that do this kind of stuff but here are my Java libraries to fill up that space!
This library uses Facebook's legacy page to scrape data.
- Login to facebook
FacebookScraper facebookScraper=FacebookScraper.builder().username(email).password(password).getInstance();
//You can also use a Proxy. Just use builder().proxy(<proxy instance>)
- Get profile information
//this method takes username or userID of your target profile
Profile profile=facebookScraper.getProfile("zuck");
- Get a list of all the friends of a user
Iterator<List<String>> it=facebookScraper.getFriends(username);
while(it.hasNext()){
List<String> friendsUsernames=it.next();
System.out.println(friendsUsernames);
}
- Get photos of a user
List<Photo> photos=facebookScraper.getPhotos("zuck");
- Search a user
List<MiniProfile> searchResults=facebookScraper.searchUsers("your search query"));
This library is a wrapper around instagram4j library which uses Instagram's private API to fetch the data. I have stripped down that library significantly and removed features like Liking a post, Commenting on a post, DMs etc. The goal of my wrapper library is only to fetch the data and not to modifying anything on the server. I have also used OkHttp instead of Apache HttpComponents to make the library Android-friendly.
- Login to Instagram
Instagram instagram=Instagram.builder().username("your username").password("your password").getInstance();
- Get profile information
Profile profile=instagram.getProfile("<username of the target>");
- Get user's timeline (photos and videos)
UserTimeline userTimeline =instagram.getUserTimeline("<username of the target>");
- Search a user
List<MiniProfile> searchResults =instagram.searchUsers("search query");
This library uses LinkedIn's private API to fetch data.
- Login to LinkedIn
LinkedIn linkedIn=LinkedIn.builder().username("your email").password("your password").getInstance();
- Get profile information
Profile profile=linkedIn.getProfile("<username or publicID of the target>");
- Search a user
List<MiniProfile> searchResults=linkedIn.searchProfile("your search query");
You can visit my another repo for this.
The entire code in this repo is released under Creative Commons BY-NC-SA 4.0 license. "This license lets others remix, tweak, and build upon your work non-commercially, as long as they credit you and license their new creations under the identical terms."