Open Graph protocol and popular use

Source: Internet
Author: User

 

Communication Protocol:

The Open Graph Protocol is a kind of specification used to mark your pages and tell us which types of real-world objects your web pages represent. Another partner website, Amazon's Internet Movie Database (IMDb), uses this Open Graph Protocol to mark pages for each Movie. Press the like button on IMDb to automatically add the movie to the "Favorite Movie" in the Facebook user profile ". Facebook has partnered with Yahoo and Twitter to adopt the OAuth 2.0 certification standard. Graph API refreshes Facebook's platform program code, giving every object in Facebook a unique ID. Using Open Graph to connect networks built on other social websites will create a smarter, more social, more personalized, and more Semantic Network.

Main tag attributes:

Og: title

Og: type

Common Value: article book movie

Og: image thumbnail address

Og: url page address

Og: Brief description of the description page

Og: the website name of the site_name page.

Og: videosrc video or Flash Address

Og: audiosrc audio address

Append attributes that everyone prefers:

Xn: page_id: ID of the Public homepage to be associated

 

Everyone's favorite implementation code:

 

  1. <Iframe src = "http://www.connect.renren.com/like? Url = <encoded_url> "style =" width: 435px; height: pixel PX; "scrolling =" no "frameborder =" 0 "allowTransparency =" true "> </iframe>

AllowTransparency indicates whether the user profile is displayed under the button. The default value is true.

 

The detailed information is added between

For example:

 

  1. <Head>
  2. <Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312"/>
  3. <Title> Renren test </title>
  4. <Meta property = "og: title" content = "Guanghua Park website Renren link test"/>
  5. <Meta property = "og: type" content = "article"/>
  6. <Meta property = "og: url" content = "http://www.ghy.cn/renren.html"/>
  7. <Meta property = "og: image" content = "http://ghy.ghy.cn/images/logo.gif"/>
  8. <Meta property = "og: site_name" content = "Guanghua Park"/>
  9. <Meta property = "og: description" content = "this is a test"/>
  10. </Head>

 

Finally, we provide a method to add using JQuery.

Add

<Span id = "notice"> </span>

 

Add in head output

 

  1. <Script type = "text/javascript">
  2. $ (Document). ready (function (){
  3. Var url = window. location. href;
  4. Var title = $ ("TITLE" pai.html ();
  5. $ ("HEAD"). append ('<meta property = "og: title" content = "' + title + '"/> ');
  6. $ ("HEAD"). append ('<meta property = "og: url" content = "' + url + '"/> ');
  7. $ ("HEAD"). append ('<meta property = "og: site_name" content = "Guanghua Park"/> ')
  8. Url = encodeURIComponent (url );
  9. Var string1 = '<iframe src = "http://www.connect.renren.com/like? Url ='
  10. Var string2 = '"style =" width: 435px; height: pixel PX; "scrolling =" no "frameborder =" 0 "allowTransparency =" true "> </iframe> ';
  11. $ ("# Notice" pai.html (string1 + url + string2 );
  12. });
  13. </Script>

The website name can be changed. You can also add parameters such as logo.

Of course, you can also encapsulate the above code into a js to make it easier to call

 

This article is from the "night light" blog

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.