내 페이지에 버튼이 있습니다. 버튼을 클릭하면, 나는이 다음 ... 페이스 북에og : 제목 og : 이미지 og : 설명 og : url 정보를 C#에서 Facebook으로
<meta property="og:title" content="Title" />
<meta property="og:description" content="Description" />
<meta property="og:url" content="url info" />
<meta property="og:image" content="image url" />
를 다음 태그 정보를 전송하려고하는 것은 내처럼 버튼 프레임
<iframe frameborder="0" scrolling="no" allowtransparency="true"
style="border: none; overflow: hidden; width: 260px; height: 35px;"
src="http://www.facebook.com/plugins/like.php?
href=http://localhost:49334/WebForm1.aspx&send=false&
layout=button_count&width=100&show_faces=false&
action=like&colorscheme=light&font=arial&height=35">
</iframe>
다음 것은 동적으로 처리 할 수있는 첫 번째 방법입니다 메타 태그. 다음
var fbTitleTag = new MetaTag
{
AgentPageURL = "/",
MetaTagName = "og:title",
UserSiteName = CurrentAgent.UserSiteName,
MetaTagContent = Request.Cookies.Get("MasterTitle").Value
};
var fbDesc = new MetaTag
{
AgentPageURL = "/",
MetaTagName = "og:description",
UserSiteName = CurrentAgent.UserSiteName,
MetaTagContent = Request.Cookies.Get("MasterDescription").Value
};
var fbUrl = new MetaTag
{
AgentPageURL = "/",
MetaTagName = "og:url",
UserSiteName = CurrentAgent.UserSiteName,
MetaTagContent = Request.Cookies.Get("MasterURL").Value
};
var fbImage = new MetaTag
{
AgentPageURL = "/",
MetaTagName = "og:image",
UserSiteName = CurrentAgent.UserSiteName,
MetaTagContent = Request.Cookies.Get("MasterImage").Value
};
var tags = new MetaTagCollection { fbTitleTag, fbDesc, fbUrl, fbImage };
Literal ltMetaTags = null;
ltMetaTags = (Literal)this.Master.FindControl("ltMetaTags");
MetaTags(tags, "wsws", "/", ltMetaTags, true);
public static void MetaTags(MetaTagCollection MetaTags, string name, string strRawURL, Literal ltlMetaHolders, bool isProp)
{
// ltlMetaHolders.Text = "";
foreach (AgentMetaTag oAgentMetaTag in agentMetaTags)
{
if (string.Compare(strRawURL, oAgentMetaTag.AgentPageURL, true) == 0)
{
if (oAgentMetaTag.MetaTagName.ToLower().Trim() != "footer" && oAgentMetaTag.MetaTagName.ToLower().Trim() != "title")
{
if (oAgentMetaTag.MetaTagName.ToLower().Trim() == "fbtitle")
oAgentMetaTag.MetaTagName = "title";
RenderMetaTagByContentName(ltlMetaHolders, oAgentMetaTag.MetaTagName, oAgentMetaTag.MetaTagContent, isProp);
}
}
}
}
public static void RenderMetaTagByContentName(Literal ltlMetaHolder, string contentName, string content, bool isProp)
{
var metaTagFromat = isProp ? "<meta property=\"{0}\" content=\"{1}\" />" : "<meta name=\"{0}\" content=\"{1}\" /> ";
ltlMetaHolder.Text += string.Format(metaTagFromat, contentName, content);
}
동적으로 메타 태그를 처리 할 수있는 두 번째 방법입니다.
HtmlMeta tag = new HtmlMeta();
tag.Attributes.Add("property", "og:title");
tag.Content = "Title";
Page.Header.Controls.Add(tag);
HtmlMeta tag1 = new HtmlMeta();
tag1.Attributes.Add("property", "og:description");
tag1.Content = "Desc";
Page.Header.Controls.Add(tag1);
HtmlMeta tagurl = new HtmlMeta();
tagurl.Attributes.Add("property", "og:url");
tagurl.Content = "URL info";
Page.Header.Controls.Add(tagurl);
HtmlMeta tagimg = new HtmlMeta();
tagimg.Attributes.Add("property", "og:img");
tagimg.Content = "Image URL";
Page.Header.Controls.Add(tagimg);
는 마지막으로 지금이 순간 내가 단지 URL을 보내는 Like button
을 클릭합니다 .. 아래와 같이
를 메타 태그를 렌더링합니다.<meta property="og:title" content="Title" /> <meta property="og:description" content="Description" /> <meta property="og:url" content="url info" /> <meta property="og:image" content="image url" />
Description/Image/Title
을 전송하지 않아야합니다."http://developers.facebook.com/tools/debug"링크를 사용 중입니다.
Description/Image/Title
이 누락되었다고합니다.어떤 아이디어?
이 하단에 표시 MyPage.cshtml 별도의 페이지에서
다음 세트 태그 값으로 Layout.cshtml에 메타 태그를 설정하려고 할 수 있습니다 내 쿼리의. –
그러나 스크랩 한 URL에 메타 데이터가 표시됩니까?Facebook 디버그 도구를 사용하고 있지만 Facebook이 귀하의 URL에서 긁어 모으는 콘텐츠에 표시되는 내용을 표시하지 않았습니다. –
메타 태그를 볼 수 없습니다. –