0

我正在开发一个代表我生成博客文章的程序。在大多数情况下,这很好用,但是当我使用 iframe 嵌入 Youtube 视频时,我的问题就来了。

出于某种原因,我的 html 被重写了。即,结束 iframe 标记被移动到帖子的末尾,然后是结束 div。

最初,我认为我错误地连接了帖子的各个片段,但是当我调试时,一切都按正确的顺序排列。

这是我实际插入的内容:

<div>
<span style="font-family: Arial, Helvetica, sans-serif, font-size: large;">
In this video, I am going to show you how to format a post for blogger. You can read the transcript below.
<br/><br/></span>
</div>
<h2>HTML Player</h2>
<div>
<iframe allowfullscreen="" frameborder="0" height="315" src="http://www.youtube.com/embed/68p_LKet2Kw&quot; width="560"></iframe>
</div>
<div>
<h2>Transcript</h2>
Sadly, my html is being re-written for some reason.
<br/><br/>
</div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif, font-size: large;">See you soon.<br/></span>
<br/>
</div>

这是在 Blogger 中生成的:

<div>
<span style="font-family: Arial, Helvetica, sans-serif, font-size: large;">
In this video, I am going to show you how to format a post for blogger. You can read the transcript below.
<br />
</span>
</div>
<h2>HTML Player</h2>
<div>
<iframe allowfullscreen="" frameborder="0" height="315" src="http://www.youtube.com/embed/68p_LKet2Kw&quot; width="560">
</div>
<div>
<h2>Transcript</h2>
Sadly, my html is being re-written for some reason.
<br/><br/>
</div>
<div>
<span style='font-family: Arial, Helvetica, sans-serif, font-size: large;'>
See you soon.
<br/><br/>
</span>
<br/>
</div>
</iframe></div>

注意关闭 iframe 标记是如何移动的,并且附加了一个额外的关闭 div。

这是我的代码:

            service = new Service("blogger", Applicationname);
            credentials = new GDataCredentials(Username, Password);
            service.Credentials = credentials;
            GDataGAuthRequestFactory bRequest = (GDataGAuthRequestFactory)service.RequestFactory;
            bRequest.AccountType = "GOOGLE";
            AtomEntry newPost = new AtomEntry();
            newPost.Title.Text = _Entry.Title;
            newPost.Content = new AtomContent();              
            BlogContent += BlogSectionTopic;
            BlogContent += "<h2>HTML Player</h2>";
            BlogContent += BlogSectionHtmlEmbed;                                
            BlogContent += "<div>";
            BlogContent += "<h2>Transcript</h2>";
            BlogContent += _BlogBody;
            BlogContent += "<br/>";
            BlogContent += "<br/>";
            BlogContent += "</div>";
            newPost.Content.Content = BlogContent;
            newPost.Content.Type = "xhtml";
            newPost.Updated = DateTime.Now;
            newPost.Published = DateTime.Now;
            Uri blogFeedUri = null;
            foreach (var category in categories.Split(','))
            {
                newPost.Categories.Add(new AtomCategory(category,new Uri("http://www.blogger.com/atom/ns#")));
            }
            newPost.Categories.Add(new AtomCategory("Video", new Uri("http://www.blogger.com/atom/ns#")));

            string tmpURI = GetPostingURI(service, "http://www.philipstirpe.co.uk/feeds/posts/default");

            if (tmpURI != "")
            {
                blogFeedUri = new Uri(tmpURI);
                 createdEntry = service.Insert(blogFeedUri, newPost);
            }

非常感谢您的任何回答和帮助。

4

1 回答 1

0

问题解决了。我终于发现我错误地将 AtomEntry 的内容类型设置为“xhtml”而不是“html”。

于 2013-10-29T21:58:38.610 回答