25 Kasım 2014 · Yazılım · 1 dk okuma
Twitter API – Kullanıcı mentionlarını getir
Bu yazı 2014 tarihli ve arşivde. İçindeki kod ve servisler bugün çalışmayabilir.
Merhaba, twitter apiyle mentionları çekmeyi gösterdim, videoda bir arkadaş sormuştu. Koda ve projeye aşağıdan ulaşabilirsiniz.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Twitter Mentions</title>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap-theme.min.css">
</head>
<body>
<?php
/**
* Twitter API
* User Mentions
* @author Selim Hallaç
* x.com/selimhallac
*/
/**
* Twitter API File
* Twitter API Dosyası
*/
include "twitteroauth/twitteroauth.php";
/**
* Twitter API Config
* Twitter API için gerekli bağlantı bilgileri
*/
$consumer_key = '';
$consumer_secret = '';
$accesstoken = '';
$accesstokensecret = '';
/**
* Twitter API Connections
* Twitter API ile bağlantı
* @var TwitterOAuth
*/
$twitter = new TwitterOAuth($consumer_key, $consumer_secret, $accesstoken, $accesstokensecret);
/**
* [$mentionList User Mention List]
* @var [type]
*/
$count = 50;
$mentionList = $twitter->get('https://api.twitter.com/1.1/statuses/mentions_timeline.json?count=50');
?>
<pre>
<table class="table table-condensed table-hover table-bordered">
<thead>
<tr>
<th>#</th>
<th>Username</th>
<th>Tweet</th>
</tr>
</thead>
<tbody>
<?php foreach ($mentionList as $key => $value) {
?>
<tr>
<td><img src="<?=$value->user->profile_image_url;?>" width="50"></td>
<td><?=$value->user->screen_name;?></td>
<td><?=$value->text;?></td>
</tr>
<?php } ?>
</tbody>
</table>
</pre>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js"></script>
</body>
</html>
İndirmek için tıklayınız ( Download )