Skip to content

Instantly share code, notes, and snippets.

@gomasaba
Created June 23, 2013 10:33
Show Gist options
  • Save gomasaba/5844552 to your computer and use it in GitHub Desktop.
Save gomasaba/5844552 to your computer and use it in GitHub Desktop.
twitteroauthでツイート取得
<?php
/**
* twitter 表示
* 1時間60回
* 1分のキャッシュ
*/
require_once getenv('DOCUMENT_ROOT').'/../lib/twitteroauth/twitteroauth/twitteroauth.php';
$consumer_key = '';
$consumer_secret = '';
$access_token = '';
$access_token_secret = '';
$memcached = new Memcached();
$memcached->addServer("localhost", 11211);
if(!$req = $memcached->get('tweet')){
$TwitterOAuth = new TwitterOAuth($consumer_key,$consumer_secret,$access_token,$access_token_secret);
$req = $TwitterOAuth->OAuthRequest("https://api.twitter.com/1.1/statuses/user_timeline.json","GET",array(
'screen_name'=>'',
"count"=>"5"
));
$memcached->add('tweet',$req,3600);
}
header("Content-Type: text/javascript; charset=utf-8");
echo $req;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment