Iphone facebook上的图片共享不起作用

Iphone facebook上的图片共享不起作用,iphone,objective-c,ios,facebook,Iphone,Objective C,Ios,Facebook,大家好,这些代码不起作用。它没有呼叫请求代表,也没有上传任何图片。你知道吗 错误来了 NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys: @"parth kausik", @"name", imageview.image, @"picture",

大家好,这些代码不起作用。它没有呼叫请求代表,也没有上传任何图片。你知道吗

错误来了

    NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                                 @"parth kausik", @"name", 
                                 imageview.image, @"picture",   
                                 nil];

  [facebook requestWithGraphPath:@"me/photos" andParams:params andHttpMethod:@"POST" andDelegate:self];
错误是:error Domain=facebookerdomain code=10000“操作无法完成。(facebookerdomain error 10000。)”UserInfo=0x6c592d0{error={type=mutable dict,count=3,
条目=>
2:{contents=“type”}={contents=“OAuthException”}
3:{contents=“message”}={contents=“必须使用活动访问令牌来查询有关当前用户的信息。”}
6:{contents=“code”}=2500
}
}
因SpringBoard的终止而终止。

只需编写参数并设置图像,如以下函数所述:

error is:Error Domain=facebookErrDomain Code=10000 "The operation couldn’t be completed. (facebookErrDomain error 10000.)" UserInfo=0x6c592d0 {error=<CFBasicHash 0x6c55f70 [0x12a9b38]>{type = mutable dict, count = 3,
entries =>
    2 : <CFString 0x6c56130 [0x12a9b38]>{contents = "type"} = <CFString 0x6c56820 [0x12a9b38]>{contents = "OAuthException"}
    3 : <CFString 0x6c567c0 [0x12a9b38]>{contents = "message"} = <CFString 0x6c56720 [0x12a9b38]>{contents = "An active access token must be used to query information about the current user."}
    6 : <CFString 0x6c59020 [0x12a9b38]>{contents = "code"} = 2500
}
}
Terminating in response to SpringBoard's termination.

添加社交框架,然后导入类,并添加以下代码

- (void) uploadImageWithName : (NSString*)name
{
    NSString *img = [NSString stringWithFormat:@"%@.png",name];
    UIImage *uploadImage = [UIImage imageNamed:img];//you can get the image on other ways also like imageView.image

    NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                                   [fb accessToken], 
                                   @"access_token",nil];

    [params setObject:uploadImage forKey:@"source"];

    [fb requestWithGraphPath:@"me/photos"
                             andParams: params
                         andHttpMethod: @"POST"
                           andDelegate:self];

}

注意:这是Xcode 4.5的工作,请检查我的答案。尚未工作。。。requestWithGraphPath方法未调用..您在fblogin后调用上载函数吗?我已经登录,在单击按钮登录后调用此方法。实现
-(void)request:(FBRequest*)request didFailWithError:(NSError*))错误
并检查错误是什么?我已经编写了参数并按照您所述设置了图像,但facebook域错误表明需要重新授权。我们怎么做检查访问令牌。。是零吗?请注意,在启动
fbdilogin
后,您需要调用
-(void)uploadImageWithName:(NSString*)name
?accesstoken为空。请在iphone开发者聊天室里聊天。我告诉过您。。你需要在fbDidLogin被激发后调用它才能获得有效的访问令牌,你说“我已经登录了”!
 SLComposeViewController *facebookPostVC =[SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook ];
[facebookPostVC setInitialText:@"iPhone Application"];
[facebookPostVC addURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@",link]]];
[facebookPostVC addImage:[UIImage imageNamed:@"Default.png"]];
[self presentViewController:facebookPostVC animated:YES completion:nil];