Message with new line character is displayed as html code

喜欢而已 提交于 2019-12-13 00:38:29

问题


I am using following code to post multiline message on facebook wall/page. but it is appear as shown in image (the text are different here). here is my code.

string path = "/me/feed";
string token = fbLoginDialog.FacebookOAuthResult.AccessToken;

dynamic messagePost = new ExpandoObject();
messagePost.message = @"Hello guys!
How are you?
Can you help me on this?";

var fb = new FacebookClient(token);
try { var postId = fb.Post(path, messagePost); }  
catch (Exception ex) { MessageBox.Show(ex.Message); }

I am using Facebook.dll Version: 5.0.1.0


回答1:


Did you try Environment.NewLine?:

messagePost.message = "Hello guys!" + Environment.NewLine + 
                      "How are you?"+ Environment.NewLine +
                      "Can you help me on this?";

Environment.NewLine is a platform independent property that inserts new line char for the selected environment.

Or maybe you have a problem with your syntax and it should be:

messagePost.message = @"Hello guys!\r\n How are you?\r\n Can you help me on this?";



回答2:


I got it working using Facebook.6.0.22

download latest from here https://github.com/facebook-csharp-sdk/facebook-winforms-sample



来源:https://stackoverflow.com/questions/13325543/message-with-new-line-character-is-displayed-as-html-code

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!