asp.net - How to send the og:Title og:Image og:Description og:url info from C# to Facebook -


i have button in page. on clicking button, trying send following tags information in 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" /> 

following button frame

<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&amp;send=false&amp;   layout=button_count&amp;width=100&amp;show_faces=false&amp;   action=like&amp;colorscheme=light&amp;font=arial&amp;height=35"> </iframe> 

following first approach dynamically handle meta tags.

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);  } 

following second approach dynamically handle meta tags.

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); 

finally rendering meta tags below..

<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" /> 

now moment click like button sends url. , not sending description/image/title.

i using link "http://developers.facebook.com/tools/debug". says description/image/title missing.

any ideas?

you don't send metadata facebook, facebook retrieves metadata page's html when loads page. try viewing url following tool:

http://developers.facebook.com/tools/debug/og/echo?q=<your url here> 

it show facebook sees (it's 'scraped url' link @ bottom of debug tool you're using now).

if not include metadata tags facebook not see them , won't add metadata open graph object. if that's case might not adding metadata html.


Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - EclipseLink JPA Object is not a known entity type -

java - Need to add SOAP security token -