Since Mountain Lion now has a built-in Facebook, I wanted to play a bit with Accounts.frameworkand Social.frameworkOS X.
I installed the application in the application for Facebook developers and used the following code to request access to the registered user’s Facebook accounts:
ACAccountStore *acStore = [[ACAccountStore alloc] init];
ACAccountType *accType = [acStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook];
NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:FB_APP_ID, ACFacebookAppIdKey, @"read_stream, publish_stream", ACFacebookPermissionsKey, ACFacebookAudienceFriends, ACFacebookAudienceKey, nil];
[acStore requestAccessToAccountsWithType:accType options:options completion:^(BOOL granted, NSError *error) {
if (granted) {
NSLog(@"Accounts: %@", acStore.accounts);
NSLog(@"Access granted");
} else {
NSLog(@"Access denied");
}
}];
Now I always get an error Error Domain=XPCObjectsErrorDomain Code=2 "The operation couldn’t be completed. (XPCObjectsErrorDomain error 2.)"
When I started the application from Xcode for the first 2-3 times, OS X displayed a confirmation dialog box “XYZ wants to access your Facebook accounts,” I clicked ok and I got an error saying something like “The application has not yet was installed. " This error has now “disappeared” and I am getting the error message above.
: - Xcode (Info.plist) Facebook, OS X? - ? : -/
WWDC 2012 Twitter/Facebook, , .
: -)
Cheers,
, ;-) NSArray, . , :
NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:
FB_APP_ID, ACFacebookAppIdKey,
[NSArray arrayWithObjects:@"read_stream", @"publish_stream", @"email", @"user_likes", nil], ACFacebookPermissionsKey,
ACFacebookAudienceFriends, ACFacebookAudienceKey, nil];
OS X , , App Facebook , OK , Facebook:
Error Domain=com.apple.accounts Code=7 "The Facebook server could not fulfill this access request: The app must ask for a basic read permission at install time."
email user_likes, . read_stream, , 190 OAuth Error validating access token: User XXXXXX has not authorized application XXXXXX.
2:
, . .