私の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];
}
}];
}
}
}];