本文整理匯總了PHP中Twitter::statusesUserTimeline方法的典型用法代碼示例。如果您正苦於以下問題:PHP Twitter::statusesUserTimeline方法的具體用法?PHP Twitter::statusesUserTimeline怎麽用?PHP Twitter::statusesUserTimeline使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Twitter
的用法示例。
在下文中一共展示了Twitter::statusesUserTimeline方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getCallback
public function getCallback()
{
$token = Input::get('oauth_token');
$verifier = Input::get('oauth_verifier');
$accessToken = Twitter::oAuthAccessToken($token, $verifier);
if (isset($accessToken['user_id'])) {
$user_id = $accessToken['user_id'];
$user = User::find($user_id);
if (empty($user)) {
$user = new User();
$user->id = $user_id;
}
Twitter::setOAuthToken($accessToken['oauth_token']);
Twitter::setOAuthTokenSecret($accessToken['oauth_token_secret']);
$timeline = Twitter::statusesUserTimeline($user->id);
$user->screen_name = $accessToken['screen_name'];
$user->profile_image_url = $timeline[0]['user']['profile_image_url'];
$user->oauth_token = $accessToken['oauth_token'];
$user->oauth_token_secret = $accessToken['oauth_token_secret'];
$user->save();
Auth::login($user);
return Redirect::to('/');
exit;
} else {
return Redirect::to('login')->with('message', 'Twitter認証できませんでした。');
exit;
}
}
示例2: Timeline
$twitter->setOAuthTokenSecret($secret);
?>
<br/><br/>
<a href='/classes/viewSource/?path=<?php
echo $_SERVER['PHP_SELF'];
?>
' target='_blank'>View Source</a><br/><br/><br/>
<a href='http://classes.verkoyen.eu/modules/twitter_oauth/files/php_twitter_2_0_3.zip'>Download twitter.php (wrapper library)</a><br/><br/>
<?php
/*-------------------------------------------------------------------------------------------------
GET USER TIMELINE
-------------------------------------------------------------------------------------------------*/
echo "<h2>User Timeline (upennClassDemos)</h2>";
$userTimeline = $twitter->statusesUserTimeline();
# Loop through the results
foreach ($userTimeline as $thisTweet) {
# Echo out each tweet
echo $thisTweet['text'] . "<br/>";
}
echo "<br/><br/>";
# For debugging purposes we can echo out the full array of the results
//print_r($userTimeline);
/*-------------------------------------------------------------------------------------------------
TRENDS
-------------------------------------------------------------------------------------------------*/
echo "<h2>Trends</h2>";
$trendsDaily = $twitter->trends();
# Loop through the results
foreach ($trendsDaily['trends'] as $thisTrend) {
示例3: showall
public function showall()
{
if (!empty($this->config['consumer_key'])) {
// create instance
$twitter = new Twitter($this->config['consumer_key'], $this->config['consumer_secret']);
// set tokens
$twitter->setOAuthToken($this->config['oauth_token']);
$twitter->setOAuthTokenSecret($this->config['oauth_token_secret']);
$mytwitteracct = $twitter->accountVerifyCredentials();
switch ($this->config['typestatus']) {
case 1:
// get users timeline including retweets
$tweets = $twitter->statusesUserTimeline(null, null, null, null, $this->config['twlimit'], null, null, true);
break;
case 2:
// get friends timeline
$tweets = $twitter->statusesFriendsTimeline(null, null, $this->config['twlimit']);
break;
case 3:
// get mentions
$tweets = $twitter->statusesMentions(null, null, $this->config['twlimit']);
break;
case 4:
// get public timeline
$tweets = $twitter->statusesPublicTimeline();
break;
default:
// get home timeline
$tweets = $twitter->statusesHomeTimeline(null, null, $this->config['twlimit']);
break;
}
if ($this->config['twlimit']) {
$tweets = array_slice($tweets, 0, $this->config['twlimit'], true);
}
$retweets = $twitter->statusesRetweetedByMe(null, null, $this->config['twlimit']);
foreach ($tweets as $key => $value) {
$tweets[$key]['retweetedbyme'] = false;
if (strpos($value['text'], 'RT ') === false) {
$tweets[$key]['text'] = $this->twitterify($value['text']);
$tweets[$key]['screen_name'] = $value['user']['screen_name'];
$tweets[$key]['image'] = $value['user']['profile_image_url'];
$tweets[$key]['via'] = $value['source'];
$tweets[$key]['ours'] = $value['user']['id'] == $mytwitteracct['id'] ? true : false;
} else {
// we're a retweet
$tweets[$key]['text'] = $this->twitterify(substr($value['text'], strpos($value['text'], ':') + 2));
// strip out RT text
$tweets[$key]['screen_name'] = isset($value['retweeted_status']['user']['screen_name']) ? $value['retweeted_status']['user']['screen_name'] : 'Unknown';
$tweets[$key]['image'] = isset($value['retweeted_status']['user']['profile_image_url']) ? $value['retweeted_status']['user']['profile_image_url'] : '';
if ($value['user']['id'] == $mytwitteracct['id']) {
$tweets[$key]['via'] = $value['source'];
$tweets[$key]['retweetedbyme'] = true;
} else {
$tweets[$key]['via'] = $value['source'] . ' (<img src="framework/modules/twitter/assets/images/rt.png" title="retweet by" alt="RT by"/> ' . $value['user']['screen_name'] . ')';
}
$tweets[$key]['ours'] = $value['user']['id'] == $mytwitteracct['id'] ? true : false;
}
// $tweets[$key]['created_at'] = strtotime($value['created_at']); // convert to unix time
$tweets[$key]['created_at'] = expDateTime::relativeDate(strtotime($value['created_at']));
// convert to unix time
if (!isset($value['retweeted_status'])) {
$tweets[$key]['retweeted_status'] = false;
}
foreach ($retweets as $rekey => $revalue) {
if ($tweets[$key]['id'] == $retweets[$rekey]['retweeted_status']['id']) {
$tweets[$key]['retweetedbyme'] = true;
break;
}
}
}
assign_to_template(array('items' => $tweets));
}
}