2012-05-11 51 views
1

你好我的名字是ryoichi。如何上傳臉書上的圖片組在目標c

我正在嘗試製作iphone應用程序。 我想在facebook上創建上傳圖片。 但我不能。我可以上傳picuture,評論我的牆。

我嘗試發佈Facebook羣組,但沒有錯誤。 只發表評論。

這是我的代碼

UIImage *img = [UIImage imageNamed:@"neko.jpg"]; 



NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys: 
           img, @"picture", @"testcomment", @"message", 
           nil]; 
[img release]; 

NSString *test [email protected]"/168782779916152/feed"; 

[[delegate facebook] requestWithGraphPath:test 
         andParams:params 
        andHttpMethod:@"POST" 
        andDelegate:self]; 

請幫助我。

+0

權限是否有誤? permissions = [[NSArray alloc] initWithObjects:@「publish_stream」,@「photo_upload,user_photos」,@「user_groups」,nil]; – ryoichi

+0

非常感謝。 dragon112和天使。 我使用didReceiveResponse mesod.so我明白我的錯誤,這很容易犯錯。錯誤:NSString * test = @「/ 168782779916152/feed」;正確:NSString * test = @「/ 168782779916152/phots」;謝謝 。 – ryoichi

回答

2

在使用它之前不要釋放img。將[img release]移到請求後面發送。

+0

謝謝你的評論。 但仍然無法正常工作。 發表評論,照片可以是我的牆。 但團體只是評論 – ryoichi

+0

謝謝。 dragon112 即時修復。 – ryoichi

0

@ dragon112發佈正確的解決方案,但它有一個錯誤。你不應該釋放該圖像,因爲你沒有分配/保留它!檢查memory management and ownership conventions。在你的例子中,只需刪除線

[img release]; 

並確保你實現了委託。

+0

謝謝你的評論。 我試試。 >並確保你實現了委託。 是什麼意思? – ryoichi

+0

嗯,這不是真的需要,但如果你想知道你的連接發生了什麼,你有委託FBRequestDelegate(https://developers.facebook.com/docs/reference/iossdk/FBRequestDelegate/)。此外,請注意,您必須先登錄並申請憑證,然後才能使用所有這些內容。 FB的一個很好的教程:https://developers.facebook.com/docs/mobile/ios/build/ –

+0

我使用didReceiveResponse mesod.so我明白我的錯誤。這很容易犯錯誤。 錯誤: NSString * test = @「/ 168782779916152/feed」; 正確: NSString * test = @「/ 168782779916152/phots」; 謝謝。 – ryoichi