我想切换到另一个帐户,通过Facebook SDK分享我的时间Feed内容。例如,我有1个个人帐户,另一个粉丝页面设置在同一个人帐户中,当用户使用我的应用程序时,我有一个功能在FB上分享内容,但我想选择我的粉丝页面帐户,而不是我的个人账户。有人有任何想法吗?感谢。
答案 0 :(得分:0)
我找到了这种情况的解决方案。我打电话给Facebook Graph API来获取当前用户拥有的页面列表,我正在使用这项服务:
[[[FBSDKGraphRequest alloc] initWithGraphPath:@"me/accounts" parameters:@{@"fields" : @"id, name, category"}]
startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
//do your stuffs here to get the pages list
}]
然后,在将帖子分享到特定页面时,我会使用其page_id并通过图谱API发送请求:NSString *pageId = [defaultDict objectForKey:@"id"];
//send photo to page
[[[FBSDKGraphRequest alloc] initWithGraphPath:[NSString stringWithFormat:@"%@/photos",pageId] parameters:@{@"source" : self.image, @"message" : [NSString stringWithFormat:@"%@ %@", self.descriptionToSend, websiteUrl]} HTTPMethod:@"POST"] startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
//do your stuff here to notify user either uploading successfully or not.
}];