我可以读取 Facebook 朋友的名字、姓氏、生日……但我无法从我的通讯录中读取 Facebook 用户名 ID。
如果 Facebook 详细信息在我手机的通讯录上,则它可以正常读取,但如果来自CardDAV 服务器则不是。
如果我去AddressBook
电话/模拟器上,我可以看到用户名......所以它们可用。
我有read_stream
, email
, read_friendlists
, publish_stream
,publish_actions
权限。
请帮忙...我的想法已经用完了
iOS6、XCode 4.5、Facebook SDK 3.1
// Extract
// These all return values
CFStringRef cfsPrefix = ABRecordCopyValue((__bridge ABRecordRef)recPerson, kABPersonPrefixProperty);
CFStringRef cfsFirstname = ABRecordCopyValue((__bridge ABRecordRef)recPerson, kABPersonFirstNameProperty);
CFStringRef cfsLastname = ABRecordCopyValue((__bridge ABRecordRef)recPerson, kABPersonLastNameProperty);
CFStringRef cfsCompany = ABRecordCopyValue((__bridge ABRecordRef)recPerson, kABPersonOrganizationProperty);
NSDate* datBirthday = (NSDate*) CFBridgingRelease(ABRecordCopyValue((__bridge ABRecordRef)recPerson, kABPersonBirthdayProperty));
NSDate* datCreate = (NSDate*) CFBridgingRelease(ABRecordCopyValue((__bridge ABRecordRef)recPerson, kABPersonCreationDateProperty));
NSDate* datModify = (NSDate*) CFBridgingRelease(ABRecordCopyValue((__bridge ABRecordRef)recPerson, kABPersonModificationDateProperty));
// This never returns a value in strFacebook
NSString *strFacebook;
ABMultiValueRef socialMulti = ABRecordCopyValue((__bridge ABRecordRef) recPerson, kABPersonSocialProfileProperty);
// ABMultiValueGetCount(socialMulti) always returns 0 ?
for (CFIndex i = 0; i < ABMultiValueGetCount(socialMulti); i++) {
NSDictionary* social = (__bridge NSDictionary*)ABMultiValueCopyValueAtIndex(socialMulti, i);
if ([social[@"service"] isEqualToString:(__bridge NSString*)kABPersonSocialProfileServiceFacebook]) {
strFacebook = (NSString*)social[@"username"];
NSLog(@"we got a facebook. username is %@ %@", [self nameForSource:(__bridge ABRecordRef)recPerson], cFacebook);
}
}