ツイートとってくる

テストついでー

テストついでー

  • タグ:
  • タグはありません
<?php
//Tr_Twit
set_include_path(realpath('./src') . PATH_SEPARATOR . get_include_path());
require_once './src/Tr/Twit.php';
// OAuth
session_start();
if (isset($_GET['clear'])) session_destroy();
$consumerKey = '';
$consumerSecret = '';
$accessToken = $_SESSION['accessToken'];
$accessTokenSecret = $_SESSION['accessTokenSecret'];
$tw = Tr_Twit::getOAuth($consumerKey, $consumerSecret);
// URI
$uri = ($_SERVER['HTTPS'] === 'on' ? 'http://' : 'https://') . $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME'];
$tw->setCallbackUri($uri);
// null
$tw->setAccessToken($accessToken, $accessTokenSecret);
// ========================================================================================
if (!$tw->checkConnection('storeToken'))
{
die('');
}
// API =====================================================================================
echo '<pre>';
// API
$screen_name = $_GET["scname"];
$page = $_GET["page"];
//$result = $tw->timeline->getUserTimeline(null, null, "");
$result = $tw->timeline->getUserTimeline(null, null, "", null, null, null, 160, null, null, null);
header("Content-Type: text/html charset=UTF-8");
echo "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />";
echo "<h1></h1>";
echo "3200<br/>";
foreach( $result as $post )
{
$text = $post["text"];
echo "Post:".$text."<br />";
echo "Posted at:".$post["created_at"]."<br />";
echo "<hr />";
}
function storeToken($token, $secret)
{
$_SESSION['accessToken'] = $token;
$_SESSION['accessTokenSecret'] = $secret;
}
?>
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX