Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Twitter APIであるTweet Web Intent のTestです。
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Twitter API(Tweet Web Intent) Test</title>
<style>
@import url(http://fonts.googleapis.com/earlyaccess/notosansjapanese.css);
html,
body {
font-size: 20px;
font-family: 'Noto Sans Japanese', sans-serif;
}
</style>
</head>
<body>
<header>
<h1>Twitter API(Tweet Web Intent) Test</h1>
</header>
<main>
<div id="div-tweet"></div>
</main>
<footer></footer>
<!-- jquery
<script src="https://coxde.jquery.com/jquery-2.1.4.min.js"></script>
-->
<script>
(function(){
// https://dev.twitter.com/web/tweet-button/web-intent
var div_tweet = document.getElementById('div-tweet');
var base_url = 'https://twitter.com/intent/tweet';
// パラメータ
var text = 'Twitter API(Tweet Web Intent) Test';
var url = 'http://cartman0.hatenablog.com/';
var via = 'cartman_eng';
var hashtags = 'はしくれエンジニア, TwitterAPI';
// 指定したユーザーがおすすめユーザーとして2アカウントまで表示
var related = 'cartman_eng';
var tweetid = 0;
var tweetLink = '<a href="' + base_url +
'?text=' + encodeURIComponent(text) +
'&url=' + url +
'&via=' + via +
'&hashtags=' + hashtags +
'&related=' + related +
// '&in-reply-to=' + tweetid +
'" target="_blank">ツイート</a>';
div_tweet.innerHTML = tweetLink;
})();
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment