Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Display Twitter Follower Using PHP
<?php
$twitter_id = "tut_web";
$url = "http://twitter.com/users/show/$twitter_id";
$response = file_get_contents ( $url );
if(empty($response)){
$count = 0;
}else{
$t_profile = new SimpleXMLElement ( $response );
$count = $t_profile->followers_count;
}
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Menampilkan Jumlah Follower Twitter Dengan PHP</title>
<style>
*{padding: 0;margin: 0;}
body{
background: -webkit-radial-gradient(circle, #FFFFFF, #00ACED);
background: -moz-radial-gradient(circle, #FFFFFF, #00ACED);
background: -o-radial-gradient(circle, #FFFFFF, #00ACED);
background: -ms-radial-gradient(circle, #FFFFFF, #00ACED);
background: radial-gradient(circle, #FFFFFF, #00ACED);
}
a{text-decoration: none; color: #0B486B;}
div{text-align: center}
div h1{
margin-top:50px;
display: block;
z-index:-1;
font-size: 30px;
}
div h2{padding: 20px;font-size: 40px}
div img{width: 100px;height: 100px;}
div h3{
width:100px;
margin: 0 auto;
background: rgba(0, 172, 237, .2);
border-radius: 50%;
padding: 100px;
font-size: 50px;
display: table;
}
div h3:hover{background:#0B486B;}
div h3:hover a{color:#fff;}
div h3 span{
display: block;
font-size: 20px;
}
</style>
</head>
<body>
<div>
<h1><a href="http://www.tutorial-webdesign.com/twitter-followers-count-php">Tutorial-Webdesign.com</a></h1>
<img src="https://twitter.com/images/resources/twitter-bird-light-bgs.png" alt="">
<h2><a href="https://www.twitter.com/<?=$twitter_id;?>">@<?=$twitter_id;?></a></h2>
<h3>
<a href="https://www.twitter.com/<?=$twitter_id;?>">
<?php echo $count;?>
<span>Followers</span>
</a>
</h3>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.