if ([FBSession.activeSession.permissions indexOfObject:@"publish_actions"] == NSNotFound)
{
// No permissions found in session, ask for it
[FBSession.activeSession reauthorizeWithPublishPermissions:[NSArray arrayWithObject:@"publish_actions"]
defaultAudience:FBSessionDefaultAudienceFriends
completionHandler:^(FBSession *session, NSError *error)
{
// If permissions granted, publish the story
if (!error)
{
[self postImageToFB] ;
}
}];
}
// If permissions present, publish the story
else
{
[self postImageToFB] ;
}
- (void) postImageToFB
{
NSData* imageData = UIImageJPEGRepresentation(self.image, 90);
NSMutableDictionary * params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
@"test", @"message",
imageData, @"source",
nil];
[FBRequestConnection startWithGraphPath:[NSString stringWithFormat:@"%@/photos",friendName]
parameters:params
HTTPMethod:@"POST"
completionHandler:^(FBRequestConnection *connection, id result, NSError *error)
{
NSLog(@"%@",error) ;
if( error == NULL )
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil
message:@"Post sucessed!!"
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil] ;
[alert show] ;
}
}];
}
に変更すると、関数を使用- (void) postImageToFB
して自分の壁に投稿できます[NSString stringWithFormat:@"%@/photos",friendName]
@"me/photos"
でも友達の壁に投稿できません、許可が間違っているのか、知らなかった問題があるのでしょうか?
これらのエラーが発生しました
Error Domain=com.facebook.sdk Code=5 "The operation couldn’t be completed. (com.facebook.sdk error 5.)" UserInfo=0xc0a7320 {com.facebook.sdk:ErrorInnerErrorKey=Error
Domain=NSURLErrorDomain Code=-1000 "bad URL" UserInfo=0xc001ea0 {NSUnderlyingError=0xaa45270 "bad URL", NSLocalizedDescription=bad URL}, com.facebook.sdk:HTTPStatusCode=200}