views:

88

answers:

2

I would like to know what this code does exactly.

- (void)dialogDidSucceed:(FBDialog*)dialog { 
//[self doSomethingExciting];
FBStreamDialog *dialog2 = [[[FBStreamDialog alloc] init] autorelease]; dialog.delegate = self;
dialog2.userMessagePrompt = @"Example prompt";
dialog2.attachment = @"{\"name\":\"Facebook iPhone SDK\","
"\"href\":\"http://developers.facebook.com/connect.php?tab=iphone\"," 
"\"caption\":\"Caption\",\"description\":\"Description\","
"\"media\":[{\"type\":\"image\"," 
"\"src\":\"http://img40.yfrog.com/img40/5914/iphoneconnectbtn.jpg\"," 
"\"href\":\"http://developers.facebook.com/connect.php?tab=iphone/\"}],"
"\"properties\":{\"another link\":{\"text\":\"Facebook home page\",\"href\":\"http://www.facebook.com\"}}}";
// replace this with a friend's UID
// dialog.targetId = @"999999"; 
[dialog2 show];

}

When I run it it asks me if I want to publish on my and my friends walls, but Im not sure how this will look on the walls. Also does it publish to the users walls and then show up in their friends incoming stream, like "most recent" or does it actually post on every friends wall?

Thanks

+1  A: 

Yes. You are posting an image to their stream.

Attachment is an escaped sequence of JSON that Facebook will pick up on and attach an image (and it looks like a link as well).

What the user will see is the image/link preconfigured as a wall post, and they will have a text box to enter their own text referred so as User Message Prompt.

Whether or not it shows up on friends streams depends on their settings, but ultimately, this is a news stream post, and thus has the potential to appear on their home page.

Jasconius
Is there a way to set the users text that the field asks for? The dialog box prompts the user and the user than can enter text? I want to set that text for them.
alJaree
My guess is no. I don't know, I've never needed to do that.
Jasconius
Thanks. SO if I want to set the description and caption to separate NSString values how would I do that? as the text is all in " " e.g. "\"caption\":\"Caption\",\"description\":\"Description\"
alJaree
It's just a big string, so you would create it with NSString stringWithFormat@"", val1, val2 -- and so on
Jasconius
Thanks for all the help. :)
alJaree
You can include a `message` as part of the JSON and that will get used as the default text. There's no way to disable the ability to edit the text, but including the message will pre-fill it. More docs [here](http://developers.facebook.com/docs/reference/rest/stream.publish).
daaku
+1  A: 

An other answer already explained what the code does.

This is just a tip: Create three fake FaceBook accounts, and connect them together. Then use them to do your testings. So you will know exactly what happens, and do all the tests you need during development without loosing all your friends.

Guillaume
haha. cool. never thought of that.(3 accounts) :P
alJaree