2012-05-08 64 views
0
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys: 
           @"parth kausik", @"name", 
           imageview.image, @"picture", 
           nil]; 

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

hello guys這些代碼無法正常工作。它不是調用請求的委託,不上傳任何picture.Do u有任何想法..Facebook中的圖片分享無法正常工作

錯誤來了....

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. 
+0

檢查我的答案[這裏](http://stackoverflow.com/q/10024056/705559)。 –

+0

還沒有工作... requestWithGraphPath方法沒有調用.. – Warewolf

+0

你是否調用fblogin之後的上傳函數? –

回答

0

只寫PARAMS並設置爲在描述圖像以下功能:

- (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]; 

} 
+0

我已經寫過參數並設置了圖像,因爲您已經描述過,但facebook域錯誤說要重新授權它。我們如何做到這一點 – Warewolf

+0

檢查訪問令牌..是否爲零? –

+0

並且在fbDidLogin被觸發後你需要調用' - (void)uploadImageWithName:(NSString *)name'? –

1

加入社會框架,然後導入類,並添加以下代碼

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]; 

注意:這是Xcode 4.5的工作