Monday

menampilkan twitter di website (2)


Twitter Headlines

Twitter Headlines is a feature that connects articles about the Tweet with the Tweet itself. When an approved publisher embeds Tweets in their content, the headline of the article and Twitter account is surfaced on the Tweet’s permalink page for all to see.
Here is a recent blog post surrounding the launch of Twitter Headlines. If you would like your site to be considered for the program, please submit an application using this form.

If you have already been approved for Headlines, you can control the attribution for your site by using twitter:site to specify your @account. For example:

<meta name="twitter:site" content="@twitterapi">

Twitter will use the canonical URL on the page if present. For example:
<link rel="canonical" href="http://example.com/your-canonical-url">

Embedding from WordPress and other CMSs

Some content management systems like WordPress have created an optimized workflow for embedding Tweets. In WordPress you can simply copy the URL for a Tweet and paste it on a single line in your post. WordPress will do the rest of the work to insert the proper embed code and make the Tweet appear in your content. For example:
https://twitter.com/BarackObama/statuses/266031293945503744

To add this behavior to your CMS, read the section below on Embedded Tweets for Developers.
Troubleshooting

If your embedded Tweets aren’t showing up in your page, there are a few things you can try.
Firstly, always remember that embedded Tweets require the <script> tag from the embed code to run to fully render the Tweet. Sometimes, a CMS may not properly format the <script> in your published articles, or may strip it out altogether. Here are ways to resolve that:

  1.  If your CMS has an ‘HTML’ or ‘code editing’ mode, use that. Often, rich-text or WYSIWYG editors will misinterpret pasted code and may remove data or try to display it in your page literally. Try entering the code in HTML mode, pasting the code directly there, and then publishing your post.
  2. If you cannot reliably work with HTML in your articles, then you or your website team should instead add a single<script> to your main website template. In your template, find the end of the page, the closing 


</body> tag, and add the following code before it.
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+"://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>

That will include the initialization code for embedded Tweets separate of your CMS content editor, and you will be able to use embedded Tweets in any page of your site without further modification.
3. If these problems do not resolve your issue, please let us know in the Developer Forums, where we can try to understand the problem, and where we can confirm that our embedded Tweets service is running at full availability.
Language

Embedded Tweets infer their language from the HTML page in which they are embedded, using the standard HTML langattribute. For example:
<html lang="es">

All Tweets on that page will be rendered in Spanish. As per HTML, the closest parent lang tag is applied to the widget. e.g.
<html lang="en">
  <head></head>
  <body>
    <article lang="fr">
      <blockquote class="twitter-tweet" />
   
You can also place an explicit lang attribute on the embed code element itself. For example:
<blockquote class="twitter-tweet" lang="ja">...</blockquote>

Note that pages without a declared language will default to English. Setting a language will translate the date, social counts, Tweet actions, and Follow button, but not the Tweet text.

sourch : twitter.com

No comments: