我有一个示例代码(iOS),其中我收到了所有用户的朋友(App Id = 377766775651612)但是当我使用自己创建的应用程序ID(应用程序ID 707496825976004)时,我收到了正在使用我的朋友列表应用
我想要所有朋友
请帮帮我
提前致谢
答案 0 :(得分:3)
Graph API版本2.0无法实现这一点。
答案 1 :(得分:1)
使用Graph API 2.0版无法做到这一点。 2014年4月之后制作的任何应用都将使用2.0。有关详细信息,请参阅以下答案: Get facebook friends with Graph API v.2.0
答案 2 :(得分:0)
-(IBAction)permit:(id)sender
{
if ( [facebook isEqualToString:@"yes"])
{
UIAlertView *Alert = [[UIAlertView alloc] initWithTitle: @"Status!"
message: @"Please Log in first"
delegate: self
cancelButtonTitle: @"Ok" otherButtonTitles: nil];
[Alert show];
}
else
{
[self requestPermissionAndPost];
}
}
- (void)requestPermissionAndPost {
[FBSession.activeSession requestNewPublishPermissions:[NSArray arrayWithObjects:@"publish_actions",@"publish_stream",@"friends_birthday", nil]
defaultAudience:FBSessionDefaultAudienceFriends
completionHandler:^(FBSession *session, NSError *error) {
if (!error && [FBSession.activeSession.permissions indexOfObject:@"publish_actions"] != NSNotFound) {
[self getFriends];
} else if (error) {
if ([FBErrorUtility errorCategoryForError:error] != FBErrorCategoryUserCancelled) {
NSLog(@"error %@",error);
}
}
}];
}
-(void)getFriends
{
[self addMBProgress];
NSString *accsstoken=[[[FBSession activeSession]accessTokenData]accessToken];
NSString *abcd=[NSString stringWithFormat:@"https://graph.facebook.com/me/friends?fields=id,name,picture,birthday,location,email&access_token=%@",accsstoken];
NSURL *url = [NSURL URLWithString:abcd];
NSMutableURLRequest *request1 = [NSMutableURLRequest requestWithURL: url];
[request1 setURL:url];
[request1 setHTTPMethod:@"GET"];
NSError *error;
NSURLResponse *response;
urlDataaa = [NSURLConnection sendSynchronousRequest:request1 returningResponse:&response error:&error];
if (urlDataaa!=nil)
{
if(NSClassFromString(@"NSJSONSerialization"))
{
NSError *error = nil;
id object = [NSJSONSerialization
JSONObjectWithData:urlDataaa
options:0
error:&error];
if(error)
{
}
if([object isKindOfClass:[NSDictionary class]])
{
NSDictionary *results = object;
NSLog(@"results..:%@",results);
[self removeMBProgress];
venues = [results objectForKey:@"data"];
NSLog(@"birthday..%@",venues);
}
}
}
[venues enumerateObjectsUsingBlock:^(NSDictionary *dict,NSUInteger idx,BOOL *stop)
{
NSString *namess = [dict objectForKey:@"name"];
[name addObject:namess];
if ([dict objectForKey:@"birthday"]) {
NSString *birthdayss = [dict objectForKey:@"birthday"];
[birthday addObject:birthdayss];
}
else
{
[birthday addObject:@"No Birthday"];
}
}
];
NSString *query1 = [NSString stringWithFormat:@"DELETE from userdata"];
[[DBManager sharedDatabase]executeQuery:query1];
NSLog(@"query1:%@",query1);
userdata = [[DBManager sharedDatabase]userdata:@"select * from userdata"];
NSLog(@"userdata...%@",userdata);
for (int i=0; i<[name count]; i++)
{
NSString *namesss =[name objectAtIndex:i];
NSString *datesss =[birthday objectAtIndex:i];
NSString *query1 = [NSString stringWithFormat:@"INSERT INTO userdata (name,date) VALUES (\"%@\",\"%@\")",namesss,datesss];
NSLog(@"query1:%@",query1);
[[DBManager sharedDatabase]executeQuery:query1];
}
userdata = [[DBManager sharedDatabase]userdata:@"select * from userdata"];
NSLog(@"userdata...%@",userdata);
[userdata addObjectsFromArray:manualdata];
[tempSearchData removeAllObjects];
[tempSearchData addObjectsFromArray:userdata];
NSLog(@"tempSearchData..%@",tempSearchData);
[friendlist reloadData];
}
答案 3 :(得分:0)
从Facebook sdk 2.0版开始,他们改变了这样的响应(获取正在使用我的应用程序的朋友列表)。我认为从特定日期开始它的行为就像那样。如果你在开发者网站注册一个新的应用程序,它可能只是那样。