Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
228 views
in Technique[技术] by (71.8m points)

iphone - Facebook installed parameter not returning data

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

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

1 Reply

0 votes
by (71.8m points)

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!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...