Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I am attempting to determine who among my facebook friends are currently using my app. The general wisdom, as far as I can tell, is to use the graph api, and send the 'installed' parameter when getting your friends list. This does not seem to be working for me, and I am wondering where I am going wrong. This is my code:

First, the permissions in effect:

_facebookPermissions = @[@"publish_stream", @"read_stream", @"friends_photos", @"user_photos"];

Now the SLRequest and it's setup:

NSString *username = [[NSUserDefaults standardUserDefaults] objectForKey:@"fbUserID"];
    NSString *urlString = [NSString stringWithFormat:@"https://graph.facebook.com/%@/friends", username];

    NSURL *friendsList = [NSURL URLWithString:urlString];
    NSDictionary *friendsListParameters = @{@"fields": @"id,name,picture,installed"};

    SLRequest *getFriends = [SLRequest requestForServiceType:SLServiceTypeFacebook requestMethod:SLRequestMethodGET URL:friendsList parameters:friendsListParameters];

Now a sample result:

{
            id = 10000123456911;
            name = "Don Dobrian";
            picture =             {
                data =                 {
                    "is_silhouette" = 0;
                    url = "https://fbcdn-profile-a.akamaihd.net/hprofile-ak-ash3/41664_100001237218111_2269_q.jpg";
                };
            };
        },

As you can see, the permissions will get me almost everything. But there is no indication at all that the 'installed' parameter was even noticed. So here are my questions, the answer to any one of which would solve my problem:

  1. Is this how you do it? What permissions are you using to get the 'installed' status?
  2. Is there a better way to get this information using the iOS Social Framework?
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
222 views
Welcome To Ask or Share your Answers For Others

1 Answer

As it happens, Ming Li was dead on with his assessment. The parameter is returned only if the friend has the app installed. An example of each:

},
                {
            id = 12645478730;
            installed = 1;
            name = "Edwin Robertson";
            picture =             {
                data =                 {
                    "is_silhouette" = 0;
                    url = "https://fbcdn-profile-a.akamaihd.net/...";
                };
            };
        },
                {
            id = 12645478730;
            name = "Greg Walker";
            picture =             {
                data =                 {
                    "is_silhouette" = 0;
                    url = "https://fbcdn-profile-a.akamaihd.net...";
                };
            };
        },

What is odd is that I was certain this did not work as expected a couple months ago when I last worked on it. Perhaps FB silently fixed something, perhaps my test user was having some issues, maybe I was just too tunnel visioned to see the fix in front of me. Who knows. But if you follow my method above, you should get this result. Good luck!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...