我有一個用紅寶石製作的博客,它的文章很少。文章保存在數據庫中。要寫內容我使用Tinymce寶石。 rss正在Feedly上工作,我想展示關於FB即時文章的文章。我也跟着上FB頁的文檔: https://developers.facebook.com/docs/instant-articles/publishing/setup-rss-feed如何在軌道上使用帶有紅寶石的FB即時文章?
,並試圖使其與在此兩個鏈接中找到的信息工作: https://www.codingfish.com/blog/129-how-to-create-rss-feed-rails-4-3-steps
和
http://apidock.com/rails/Builder/XmlMarkup
有時FB就裝好文章但風格不見了,找不到任何內容,找不到任何文章,然後我得到了「出錯了......」的錯誤,不得不等待一段時間,等等。 我不知道該怎麼做。這是feed.rss.builder的最後一個版本,FB不能看到任何東西(您還沒有創建任何即時文章)。
#encoding: UTF-8
xml.instruct! :xml, :version => "1.0"
xml.rss :version => "2.0" do
xml.channel do
xml.title "Blog"
xml.author "Blog"
xml.description "Web Development"
xml.link "http://myblog.dev.eu/"
xml.language "en"
for article in @blog_articles
xml.item do
if article.title
xml.title article.title
else
xml.title ""
end
xml.link("href" => "http://myblog.dev.eu/blog_posts/"+article.slug.to_s)
xml.guid article.id
xml.pubDate article.created_at.to_s(:rfc822)
xml.author article.author_name
xml.description article.short_description
xml.html do
xml.head do
xml.link("rel" => "stylesheet", "title" => "default", "href" => "#")
xml.title(article.title)
xml.meta("property" => "fb:article_style", "content" => "bam")
xml.link("rel" => "canonical", "href" => "http://myblog.dev.eu/blog_posts/"+article.slug.to_s)
end
xml.body do
xml.header do
xml.image "http://myblog.dev.eu/" + article.picture_url.to_s
end
xml.article(article.content)
end
end
end
end
end
end
請幫我解決這段代碼!我想提交它用於審查,並且不再觸摸feed.rss.builder中的代碼。謝謝!
編輯:
我已經在代碼改變一些東西,現在看起來這樣:
#encoding: UTF-8
xml.instruct! :xml, :version => "1.0"
xml.rss :version => "2.0", "xmlns:content"=>"http://purl.org/rss/1.0/modules/content/" do
xml.channel do
xml.title "MyBlog"
xml.link "http://myblog/"
xml.description "Web Development, Digital Marketing, Education"
xml.language "en-us"
xml.lastBuildDate Time.new.strftime("%Y-%-m-%dT%H:%M").to_s
for article in @blog_articles
xml.item do
xml.title article.title
xml.link "http://myblog.eu/"+article.slug.to_s
xml.guid article.id
xml.pubDate article.created_at.strftime("%Y-%-m-%dT%H:%M").to_s
xml.author article.author_name
xml.description article.short_description
xml.content:encoded do
xml.tag!("!doctype html")
xml.html("lang"=>"en", "prefix"=>"op:http://media.facebook.com/op#") do
xml.head do
xml.meta("charset"=>"utf-8")
xml.link("rel" => "stylesheet", "title" => "default", "href" => "#")
xml.title(article.title)
xml.link("rel" => "canonical", "href" => "http://myblog.eu/blog_posts/"+article.slug.to_s)
xml.meta("property" => "fb:article_style", "content" => "bam")
end
xml.body do
xml.article do
xml.header do
xml.figure("data-mode" => "aspect-fit") do
xml.img("src"=>"http://myblog.eu/blog_posts/#{article.picture.url}")
end
xml.h1 article.title
xml.h2 article.short_description
xml.h3("Introduction" , "class"=>"op-kicker")
xml.address "myadr"
xml.time(article.created_at.strftime("%B %dth %Y, %l:%M %p").to_s, "class" => "op-published", "dateTime" => article.created_at.strftime("%Y-%-m-%dT%H:%M").to_s)
xml.time(article.created_at.strftime("%B %dth %Y, %l:%M %p").to_s, "class" => "op-modified", "dateTime" => article.updated_at.strftime("%Y-%-m-%dT%H:%M").to_s)
end
xml.p article.content
xml.figure("data-feedback"=>"fb:likes, fb:comments") do
xml.img("src"=>"http://myblog.eu/blog_posts/#{article.picture.url}")
xml.figcaption do
xml.h1 "descript"
xml.cite "text"
end
end
xml.footer do
xml.small "Lab"
end
end
end
end
end
end
end
end
end
現在FB認識的文章,但我仍然有錯誤:「缺少的標誌」。我加入FB風格的標誌,它可以在網上找到:
xml.meta("property" => "fb:article_style", "content" => "bam")
當我打開FB編輯一篇文章的全部內容在文章標籤頭標記前加入。它看起來是這樣的:
<html>
<body><article><p>!doctype html/>
...Content...
</p>
<header><time class="op-modified" datetime="2016-01-19T10:38:00-08:00">2016-01-19T10:38:00-08:00</time><time datetime="2016-01-19T10:38:00-08:00" class="op-published"></time><h1>Title</h1></header><footer></footer></article></body>
<head><link rel="canonical" href="http:///myblog.eu/article.title"></head>
</html>
而且它還沒有準備好進行審查。有任何想法嗎?