【问题标题】:Share image on facebook using FBConnect使用 FBConnect 在 Facebook 上分享图像
【发布时间】:2011-08-29 13:27:22
【问题描述】:

在上面搜索了 2 天后,我终于发布了我的代码。

应用说明:我正在通过 imagePicker 选择图像,编辑后我想在 Facebook 上分享。

问题:我可以在墙上发布文字但不能在墙上发布图片,因为我没有任何 URL,我无法找到另一种在墙上发布图片的方式。

这是我的 PostToWall 的代码(我从另一个应用程序中窃取的)

FBStreamDialog* dialog = [[[FBStreamDialog alloc] init] autorelease];
dialog.userMessagePrompt = @"Enter your message:";
dialog.actionLinks = @"[{\"Get DowntownLA!\",\"href\":\"http://www.facebook.com/DowntownLA.com/\"}]";
dialog.attachment = [NSString stringWithFormat:
                     @"{ \"name\":\"%@\","
                     "\"href\":\"%@\","
                     "\"caption\":\"%@\",\"description\":\"%@\","
                     "\"media\":[{\"type\":\"image\","
                     "\"src\":\"%@\","
                     "\"href\":\"%@\"}],"
                     "\"properties\":{\"%@\":{\"text\":\"%@\",\"href\":\"%@\"}}}", @"name: priya",@"href nothing",@"cation nothing",@"description nothin", @"imageSource nothing ", @"imageHref nothing", @"linkTitle nothing", @"linkText nothing", @"linkHref nothing"];


[dialog show];

请告诉我哪里出错了!!!!!!

在模拟器上出现的错误是:应用程序响应错误 - 后操作链接必须是有效的 URls。您可以看到这一点,因为您是该应用的开发者之一。

【问题讨论】:

    标签: iphone objective-c cocoa-touch facebook fbconnect


    【解决方案1】:

    我有这种方式上传图片

    - (void) postOnFBWall
    

    {

    NSMutableDictionary *variables = [NSMutableDictionary dictionaryWithCapacity:2];
    
    //create a UIImage (you could use the picture album or camera too)
    UIImage *picture = imgUploadPhoto.image;
    
    //create a FbGraphFile object insance and set the picture we wish to publish on it
    FbGraphFile *graph_file = [[FbGraphFile alloc] initWithImage:picture];
    
    //finally, set the FbGraphFileobject onto our variables dictionary....
    [variables setObject:graph_file forKey:@"file"];
    
    NSString * messageValue = [NSString stringWithFormat:@"Menu Name: %@, Restaurant: %@, Category: %@, Comment: %@",txtNameofMenu.text,txtRestaurant.text,categoryLbl.text,txtViewComment.text];
    
    [variables setObject:[NSString stringWithFormat:@"%@",messageValue] forKey:@"message"];
    
    //the fbGraph object is smart enough to recognize the binary image data inside the FbGraphFile
    //object and treat that is such.....
    FbGraphResponse *fb_graph_response = [[FBRequestWrapper defaultManager] doGraphPost:@"me/photos" withPostVars:variables];
    NSLog(@"postPictureButtonPressed:  %@", fb_graph_response.htmlResponse);
    

    }

    【讨论】:

    • 我无法包含 FbGraphFile。我得到了 6 个错误,:错误:未声明“FbGraphFile”(在此函数中首次使用)错误:未声明“graph_file”(在此函数中首次使用)错误:未声明“messageValue”(在此函数中首次使用)错误:未声明“FbGraphResponse” (在此函数中首次使用)错误:'fb_graph_response'未声明(在此函数中首次使用)错误:'FBRequestWrapper'未声明(在此函数中首次使用)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-01-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多