在我的 iphone 应用程序中,我想将照片发布到选定的 Facebook 联系人。我正在从电话库中获取这些照片。
我正在使用这段代码:
fbString=[NSString stringWithFormat:@"%@\n%@",appdelegate.titleString,appdelegate.descriptionString];
NSArray *permissions =[NSArray arrayWithObjects:@"publish_actions",@"publish_stream",@"manage_friendlists", nil];
NSData* imageData = UIImageJPEGRepresentation(self.img, 90);
NSLog(@"imageData %@",imageData);
NSMutableDictionary *params = [[NSMutableDictionary alloc] initWithObjectsAndKeys:fbString, @"message",imageData,@"source",nil];
NSLog(@"fbid count %d",fbidarray.count);
[[FBSession activeSession] reauthorizeWithPublishPermissions:permissions
defaultAudience:FBSessionDefaultAudienceFriends
completionHandler:^(FBSession *session, NSError *error)
{
if (!error) {
for(int j=0;j<fbidarray.count;j++)
{
[FBRequestConnection startWithGraphPath:[NSString stringWithFormat:@"%@/photos",[fbidarray objectAtIndex:j]] parameters:params HTTPMethod:@"POST" completionHandler:^(FBRequestConnection *connection, id result, NSError *error1)
{
NSLog(@"errors in the view %@",error1);
if(!error1 )
{
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Success"
message:[NSString stringWithFormat:@" Sucessfully posted "]
delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alertView show];
}
}];
}
}
}];