2011-05-10 100 views
0

我試圖將視頻上傳到Wordpress.using以下方法iframe標籤未顯示C#

string expression = videoData.VideoTitle; 
string str7 = videoData.VideoTitle;  
WebClient client = new WebClient(); 
client.Headers.Add("Content-Type", "application/x-www-form-urlencoded"); 
string s = "security_code=JGZpbGVu&post_content=<iframe width='480' height='390' src='http://www.youtube.com/embed/XkIdmC8MlkI' frameborder='0' allowfullscreen></iframe>" 
        + "&post_title=" + expression + "&post_category=" 
        + "&post_category=" + category + "&category=" + category + "&post_name=" + str7 + "&post_date=" + DATE_STRING; 
byte[] bytes = Encoding.ASCII.GetBytes(s); 
byte[] buffer2 = client.UploadData(uploadPath, "POST", bytes); 
string str8 = Encoding.ASCII.GetString(buffer2).ToString(); 

它的工作原理,一切都貼出但在標籤的東西沒有得到貼我嘗試了一些夫婦的事情什麼結果out是它有標籤問題。 當我刪除iframetag的<它顯示,但直到url和之後,一切都消失了。 這裏是不執行以及

"security_code=JGZpbGVu&post_content=test iframe width='480' height='390' src='http://www.youtube.com/embed/XkIdmC8MlkI' frameborder='0' allowfullscreen></iframe>&post_title=How to build, upgrade, or repair, your own PC Computer&post_category=&post_category=asd&category=asd&post_name=How to build, upgrade, or repair, your own PC Computer&post_date=2011-05-11 00:00:00" 

任何想法的東西有什麼不好?

+0

我們可以看到,當這貼_is_生成HTML是什麼? – Chad 2011-05-10 19:19:34

+0

Html在字符串s? – 2011-05-10 19:24:11

+0

@Afnan就像你打這個電話後,訪問你的Wordpress驅動的網站,你看到新帖子是正確的?複製該頁面的HTML(最好只是有問題的部分)併發布給我們看。 – Chad 2011-05-10 19:26:24

回答

1

您可能需要登錄URL-encode HTML。

確保您引用的System.Web,則:

string html = @"<iframe width='480' height='390' src='http://www.youtube.com/embed/XkIdmC8MlkI' frameborder='0' allowfullscreen></iframe>"; 
string s = string.Format("security_code=JGZpbGVu&post_content={0}&post_title={1}&post_category={2}&category={3}&post_name={4}&post_date={5}", System.Web.HttpUtility.UrlEncode(html), expression, category, category, str7, DATE_STRING); 
+0

時已經顯示''client.Headers.Add(「Content-Type」,「application/x-www-form-urlencoded」);' – 2011-05-10 19:43:57

+0

@Afnan:你需要實際對URL進行URL編碼,看到更新的答案。 – svinto 2011-05-10 20:23:35

+0

不,即使這並沒有幫助 – 2011-05-10 20:48:07