簡體   English   中英

使用圖API iPhone iPhone SDK在Facebook牆上發布圖片

[英]Post image on facebook wall using graph api iphone sdk

我一直在嘗試使用facebook graph API在Facebook上發布照片。 驗證用戶身份后,我正在執行以下操作

        NSMutableDictionary *variables = [[NSMutableDictionary alloc]init];
        [variables setObject:@"some text" forKey:@"message"];
        [variables setObject:@"some link" forKey:@"link"];
        [variables setObject:[UIImage imageNamed:@"icon@2x.png"] forKey:@"picture"];

        NSString *str = @"me/feed";
        NSLog(@"str: %@", str);
        FbGraphResponse *resp = [self.fbGraph doGraphPost:str withPostVars:variables];
        NSLog(@"resp: %@", resp.htmlResponse);

但是我的應用因拋出異常而崩潰:

    *** Terminating app due to uncaught exception 'NSInvalidArgumentException', 
reason: -[UIImage dataUsingEncoding:]: unrecognized selector sent to instance 0x11545140'

因此,有人可以幫助我如何使用圖形API將圖片以及一些消息發布到Facebook牆上。

使用下面的代碼

NSMutableDictionary *variables = [NSMutableDictionary dictionaryWithCapacity:3];

//create a UIImage (you could use the picture album or camera too)
//UIImage *picture =selectimage.image;
UIImage *picture =[self scaleAndRotateImage:selectimage.image];

FbGraphFile *graph_file = [[FbGraphFile alloc] initWithImage:picture];

    [variables setObject:graph_file forKey:@"file"];

    [variables setObject:myPost.text forKey:@"message"];

    FbGraphResponse *fb_graph_response = [fbGraph doGraphPost:@"me/photos" withPostVars:variables];

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM