简体   繁体   中英

How will this code publish an image to a wall using Facebook Connect?

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

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM