2011-08-29 86 views
-1

搜索了2天后,终于发布了我的代码。使用FBConnect在脸书上分享图片

应用说明:我正在通过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]; 

请电话我wher要去错误(这是我从另一个应用程序偷)!!!!!

模拟器上的错误是:Application Response Error - 后处理链接必须是有效的URls。你可以看到这个,因为你是该应用程序的开发人员之一。

回答

0

我必须上传图片这样

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

}

+0

我无法包括FbGraphFile。 IGOT 6个错误,:错误:“FbGraphFile”未声明(在此函数首先使用) 错误:“graph_file”未声明(先入该函数使用) 错误:“messageValue”未申报(先入该函数使用) 错误:“FbGraphResponse”未声明(在一次使用此功能) 错误:未声明“fb_graph_response”(在一次使用此功能) 错误:“FBRequestWrapper”未申报(第一在此函数使用) –