Join CSnippTM today and be a part of 5,000+ developers like you. for FREE !!!
  Liked by 1 user    Fork

Find list of your facebook friends who a have liked atleast one post in a particular page   1312


Quick snippet to find a list of your friends who have liked atleast one post in a particular page in Facebook.

Short url  
import facebook4j.Facebook;
import facebook4j.FacebookFactory;
import facebook4j.auth.AccessToken;

public class FbClass {

        public static void main(String[] args) throws Exception
                Facebook facebook = new FacebookFactory().getInstance();
                String appId="your_app_id_here";
                String appSecret="your_app_secret_id_here";
                facebook.setOAuthAppId(appId, appSecret);
                 String accessToken="your_access_token_here";
                facebook.setOAuthAccessToken(new AccessToken(accessToken, null));
                String query = "select message FROM stream where post_id IN (select post_id FROM like WHERE post_id IN (select post_id from stream where source_id ='your_page_id' and likes.count > 0 limit 200) AND user_id IN (SELECT uid2 FROM friend WHERE uid1 = me() ))";

                //execute query
                JSONArray jsonArray = facebook.executeFQL(query);
           //parse the json returned  
           for (int i = 0; i < jsonArray.length(); i++)
                    JSONObject jsonObject = jsonArray.getJSONObject(i);


  • 820e01609a9f8f0fc0d5167680625b93
    Harisankar P S

    Wow, 200+ views in a single day. Congrats @yackoa

  • 8e4ee1163c3c9a053d1ca5244c0ffc88

    Cool :D

  • 3772186e95cc0c66c42a0e9b5d188991
    Sander Joseph

    Bad timing BRO..

    facebook updated the version.

    So this fql wont work now :(

  • 8e4ee1163c3c9a053d1ca5244c0ffc88

    yup saw it in the documentation. I will port it soon :)

    But I think it would have been hilarious when you got the error during demo.

Register/Login to Chat and take part in the discussion


Yacko  (23)

Click to view more