Поделиться изображением на Facebook с помощью FBConnect - PullRequest
0 голосов
/ 29 августа 2011

После 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,Вы можете видеть это, потому что вы один из разработчиков приложения.

1 Ответ

0 голосов
/ 29 августа 2011

У меня есть изображение для загрузки таким образом

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

}

...