本文整理匯總了PHP中Twitter::getUserTimeline方法的典型用法代碼示例。如果您正苦於以下問題:PHP Twitter::getUserTimeline方法的具體用法?PHP Twitter::getUserTimeline怎麽用?PHP Twitter::getUserTimeline使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Twitter
的用法示例。
在下文中一共展示了Twitter::getUserTimeline方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: _checkForTwitterUpdates
protected function _checkForTwitterUpdates()
{
$cache_time = 300;
$cache_filepath = DIR_CACHE . 'twitter-' . APIA_TWITTER_USER . '-pull-ts.cache';
$last_pull_time = (int) @file_get_contents($cache_filepath);
$now_time = time();
if ($now_time - $last_pull_time > $cache_time) {
/* get the last entered twitter entry */
$query = 'SELECT UNIX_TIMESTAMP(creativeartsguide.feed.timestamp) AS time
FROM creativeartsguide.feed
WHERE creativeartsguide.feed.type=3
ORDER BY creativeartsguide.feed.timestamp DESC
LIMIT 1';
$DbStmt = $this->getDatabase()->prepare($query)->execute();
$DbStmt->first();
$last_item_pulled = $DbStmt->time ? $DbStmt->time : 00;
$last_item_pulled = (int) $last_item_pulled + 1;
/* use Twitter API class to get XML return for request */
$Twitter = new Twitter(APIA_TWITTER_USER, APIA_TWITTER_PASS);
$twitter_xml = $Twitter->getUserTimeline();
$twitter_status = new SimpleXMLElement($twitter_xml);
$i = 0;
/* loop through each returned tweet (or status) */
foreach ($twitter_status->status as $s) {
/* get the information we need from the object */
$t_time = (int) strtotime($s->created_at);
$t_fav = (string) $s->favorited;
$t_text = (string) $this->_addTwitterLinks($s->text);
/* skip any posts that are already in the database */
if ($last_item_pulled > $t_time) {
continue;
}
/* skip any posts that are not favorited */
if ((string) $s->favorited != 'true') {
continue;
}
/* insert new twitter post id and timestamp */
$query = 'INSERT INTO :T1
SET :T1.type=:A1,
:T1.timestamp=FROM_UNIXTIME(:A2)';
$DbStmt = $this->getDatabase()->prepare($query, array('creativeartsguide.feed'))->execute(array(3, $t_time));
$insert_id = $DbStmt->insertId();
/* insert new twitter post content */
$query = 'INSERT INTO :T1
SET :T1.feed_id=:A1, :T1.post=:A2';
$DbStmt = $this->getDatabase()->prepare($query, array('creativeartsguide.feed_post'))->execute(array($insert_id, $t_text));
}
/* cache this data... */
$fhandle = fopen($cache_filepath, 'wb');
fwrite($fhandle, time());
fclose($fhandle);
}
}
示例2: update
public function update()
{
$pseudos = Name::all();
$name = Input::get('pseudo');
$db_name = Name::where('screen_name', '=', $name)->first();
if (isset($db_name->screen_name) && strtolower($name) == strtolower($db_name->screen_name)) {
// Le pseudo existe déjà dans la BDD, on affiche directement
$twitter = Tweet::where('name_id', '=', $db_name->id)->paginate(20);
return View::make('twitter', compact('twitter', 'pseudos'))->with(['name' => $name]);
} else {
$author = Twitter::getUserTimeline(array('screen_name' => $name, 'count' => 1));
if (isset($author->errors)) {
$erreur = 'Il n\'existe pas d\'utilisateur au nom de ' . $name;
return View::make('twitter')->with(['name' => $name, 'erreur' => $erreur]);
} else {
// Le pseudo n'existe pas dans la base de donnée, on créé une entrée et on récupère ses tweets favoris
TwitterFav::createUser($author);
$name_id = Name::where('screen_name', '=', $author[0]->user->screen_name)->first();
$req_twitter = Twitter::getFavorites(array('screen_name' => $name, 'count' => 200, 'format' => 'object'));
if (isset($req_twitter->errors)) {
echo 'Trop de requetes, veuillez patienter.';
exit;
}
while ($req_twitter != 0) {
// On ajoute les tweets favoris en BDD
$max_id = TwitterFav::addFavoris($req_twitter, $name_id);
$req_twitter = Twitter::getFavorites(array('max_id' => $max_id, 'screen_name' => $name, 'count' => 200, 'format' => 'object'));
if (isset($req_twitter->errors)) {
echo 'Trop de requetes, veuillez patienter.';
exit;
}
sleep(10);
}
$twitter = Tweet::where('name_id', '=', $name_id->id)->paginate(25);
$pseudos = Name::all();
return View::make('twitter', compact('twitter', 'pseudos'))->with(['name' => $name]);
}
}
}
示例3: function
Route::post('markfeed', 'FeedbackController@markfeed');
//pie graph data
Route::get('userStatus', 'GraphController@userStatus');
//line chart dat
Route::get('userRegistrations', 'GraphController@userRegistrations');
//cards data
Route::get('userStats', 'GraphController@userStats');
//retrives no of notifications
Route::get('notifications', 'AdminNotificationController@getNotificationNumber');
//retrives all unread notifications
Route::get('notificationlist', 'AdminNotificationController@getNotificationList');
//sets notifications to read notifications
Route::get('readNotifications', 'AdminNotificationController@setOne');
});
Route::get('/feeds', function () {
return Twitter::getUserTimeline(['screen_name' => 'rajikaimal', 'count' => 2, 'format' => 'json']);
});
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| This route group applies the "web" middleware group to every route
| it contains. The "web" middleware group is defined in your HTTP
| kernel and includes session state, CSRF protection, and more.
|
*/
Route::group(['middleware' => ['web']], function () {
//
});
Route::group(['middleware' => 'web'], function () {
示例4: tts
function tts()
{
$twitter = new Twitter("likelevent", "test8899");
var_dump($twitter->getUserTimeline());
exit;
}
示例5: Twitter
echo "\n";
?>
</div><!--googleon: snippet-->
<div id="right"><!--googleoff: snippet-->
<?php
// require the twitter library
require "twitterlibphp/twitter.lib.php";
include 'search.php';
try {
// your twitter username and password
$username = "USERNAME";
$password = "PASSWORD";
// initialize the twitter class
$twitter = new Twitter($username, $password);
// fetch user's timeline in xml format
$xml = $twitter->getUserTimeline();
$twitter_status = new SimpleXMLElement($xml);
$i = 0;
foreach ($twitter_status->status as $status) {
if ($i < 10) {
if ($i == 0) {
echo "\t\t\t\t";
} else {
echo "\n\t\t\t\t";
}
echo '<p>';
$tweet = toLink($status->text);
echo $tweet;
echo '<br />';
echo "\n\t\t\t\t";
$date = preg_split("/[\\s,:]+/", $status->created_at);
示例6: function
$twitterFollowersLink .= '<i class="fa fa-twitter fa-fw twitter"></i> ';
}
if ($attributes['with_text'] != false) {
$twitterFollowersLink .= $attributes['text'];
}
$twitterFollowersLink .= '<span class="' . $extraClasses . '">';
$twitterFollowersLink .= $totaltwitterFollowers;
$twitterFollowersLink .= '</span>';
if ($attributes['link_enabled'] != false) {
$twitterFollowersLink .= '</a>';
}
return $twitterFollowersLink;
});
// SHOW TWITTER TIMELINE - #reference StatusTrait.php
HTML::macro('twitter_lookup_timeline', function ($user, $count = 20) {
$twitterRole = Twitter::getUserTimeline(['screen_name' => $user, 'count' => $count, 'format' => 'json']);
$parsed_json = json_decode($twitterRole, true);
$result = '';
//dd($parsed_json);
foreach ($parsed_json as $key => $value) {
$result .= $value['created_at'] . ' | ' . $value['text'] . ' | ' . $value['retweet_count'] . '<br />';
}
return $result;
});
HTML::macro('twitter_user_home_timeline', function ($user, $count = 20) {
$twitterRole = Twitter::getHomeTimeline(['screen_name' => $user, 'count' => $count, 'format' => 'json']);
$parsed_json = json_decode($twitterRole, true);
//dd($parsed_json);
$result = '<ul class="timeline">';
$result .= '<li class="time-label">';
$result .= '<span class="bg-red">';
示例7: Twitter
<div class="twitter_container">
<?php
// require the twitter library
require "twitter.lib.php";
// your twitter username and password
$username = "MelissaSavcic";
$password = "mel2ssa";
// initialize the twitter class
$twitter = new Twitter($username, $password);
// fetch public timeline in xml format
$options = array('count' => 2);
$xml = $twitter->getUserTimeline($options);
$twitter_status = new SimpleXMLElement($xml);
foreach ($twitter_status->status as $status) {
foreach ($status->user as $user) {
echo '<img src="' . $user->profile_image_url . '" class="twitter_image">';
echo '<a href="http://www.twitter.com/MelissaSavcic">' . $user->name . '</a> ';
}
echo $status->text;
echo '<br/>';
echo '<br/>';
//echo '<div class="twitter_posted_at">Posted at:'.$status->created_at.'</div>';
}
echo '</div>';
?>
<img src="images/sidebar-bot.gif"></img>
示例8: function
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
| http://laravel.com/docs/5.1/authentication
| http://laravel.com/docs/5.1/authorization
| http://laravel.com/docs/5.1/routing
| http://laravel.com/docs/5.0/schema
| http://socialiteproviders.github.io/
|
*/
// HOMEPAGE ROUTE
Route::get('/', function () {
return view('welcome');
});
Route::get('/twitter', function () {
return Twitter::getUserTimeline(['screen_name' => 'jeremyekenedy', 'count' => 20, 'format' => 'json']);
//return Twitter::getHomeTimeline(['count' => 20, 'format' => 'json']);
//return Twitter::getMentionsTimeline(['count' => 20, 'format' => 'json']);
//return Twitter::postTweet(['status' => 'Laravel is beautiful', 'format' => 'json']);
});
// ALL AUTHENTICATION ROUTES - HANDLED IN THE CONTROLLERS
Route::controllers(['auth' => 'Auth\\AuthController', 'password' => 'Auth\\PasswordController']);
// REGISTRATION EMAIL CONFIRMATION ROUTES
Route::get('/resendEmail', ['as' => 'user', 'uses' => 'Auth\\AuthController@resendEmail']);
Route::get('/activate/{code}', ['as' => 'user', 'uses' => 'Auth\\AuthController@activateAccount']);
// CUSTOM REDIRECTS
Route::get('restart', function () {
\Auth::logout();
return redirect('auth/register')->with('anError', \Lang::get('auth.loggedOutLocked'));
});
Route::get('another', function () {
示例9: twitterTimeline
public function twitterTimeline($twitter_account)
{
return Twitter::getUserTimeline(array('screen_name' => $twitter_account, 'count' => 5, 'format' => 'json'));
}
示例10: getTimeline
public function getTimeline()
{
$screen_name = \Session::get('access_token')['screen_name'];
// return \Twitter::getHomeTimeline(['count' => 20, 'format' => 'json']);
return \Twitter::getUserTimeline(['screen_name' => $screen_name, 'count' => 20, 'format' => 'json']);
}
示例11: function
<?php
Route::get('/', 'HomeController@index');
Route::get('events', 'EventsController@index');
Route::get('persons', 'PersonsController@index');
Route::get('/test', function () {
return Twitter::getUserTimeline(['screen_name' => 'catnatnet', 'count' => 100, 'format' => 'json']);
});
Route::resource('events', 'EventSController');
示例12: function
<?php
use Route;
Route::get('api/noaa', ['as' => 'noaa_rss_api', 'uses' => '\\NoaaRss\\Controllers\\Api\\NoaaRssApiController@index']);
Route::get('noaa', ['as' => 'noaa_rss', 'uses' => '\\NoaaRss\\Controllers\\Site\\NoaaRssController@index']);
Route::get('tweets', function () {
return \Twitter::getUserTimeline(['screen_name' => 'WATT_fm', 'count' => 20, 'format' => 'json']);
});