本文整理匯總了PHP中Twitter::showUser方法的典型用法代碼示例。如果您正苦於以下問題:PHP Twitter::showUser方法的具體用法?PHP Twitter::showUser怎麽用?PHP Twitter::showUser使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Twitter
的用法示例。
在下文中一共展示了Twitter::showUser方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: widget_twitter_widget
public function widget_twitter_widget($h)
{
// your twitter username and password
$twitter_widget_username = $h->getSetting('twitter_widget_username', 'twitter_widget');
$twitter_widget_password = $h->getSetting('twitter_widget_password', 'twitter_widget');
// include Twitterlibphp
require_once PLUGINS . 'twitter_widget/libs/twitter_lib.php';
// initialize the twitter class
$twitter = new Twitter($twitter_widget_username, $twitter_widget_password);
///// testing purposes (doesn't count against your hit limit to call up remaining hits)
if ($h->isDebug) {
// grabs status for API rate limit for testing cache
$calls = $twitter->rateLimitStatus();
$hits = new SimpleXMLElement($calls);
echo '<br/>';
echo 'remaining hits for this hour = ' . $hits->{'remaining-hits'};
}
$need_cache = false;
// check for a cached version and use it if no recent update:
$cached_output = $h->smartCache('html', 'posts', 10, '', 'twitter_widget');
if ($cached_output) {
echo $cached_output;
// cached HTML
return true;
} else {
$need_cache = true;
}
// fetch your profile in xml format
$user = $twitter->showUser();
$my_info = new SimpleXMLElement($user);
// fetch your friends (people you follow) in xml format or use getUserTimeline() to show your own
$xml = $twitter->getFriendsTimeline();
// fetch your session xml format
$twitter_status = new SimpleXMLElement($xml);
// trim characters to show for each tweet
function ShortenText($text)
{
// Change here. default 77
$chars = 77;
$text = $text . " ";
$text = substr($text, 0, $chars);
$text = substr($text, 0, strrpos($text, ' '));
$text = $text . "...";
return $text;
}
// show twitter widget template
$output = "<div class='twitter_container'>\n";
$output .= "<div class='twitter_header'>\n";
$output .= "<img src='" . $my_info->profile_image_url . "' alt=" . $my_info->screen_name . " title=" . $my_info->screen_name . " >\n";
$output .= "<h3><a href='http://www.twitter.com/" . $my_info->screen_name . "'>" . $my_info->followers_count . " " . $h->lang['twitter_widget_followers'] . "</a></h3>\n";
//$output .= "<br/>\n";
$output .= "<a href='http://www.twitter.com/" . $my_info->screen_name . "'>" . $h->lang['twitter_widget_follow_us'] . "</a>\n";
$output .= "</div>\n";
$i = 1;
foreach ($twitter_status->status as $status) {
if ($i < 6) {
//show up to 20 latest tweets default is 5
$output .= "<div class='twitter_status'>\n";
foreach ($status->user as $user) {
$output .= "<img src='" . $user->profile_image_url . "' alt=" . $user->screen_name . " title=" . $user->screen_name . " class='twitter_image'>\n";
$output .= "<a href='http://www.twitter.com/" . $user->screen_name . "'>" . $user->name . "</a>: \n";
}
$output .= ShortenText($status->text);
$output .= "<br/>\n";
// uncommment below to show posted time - might have to adjust CSS!
//$output .= "<div class='twitter_posted_at'><strong>Posted at:</strong> ".$status->created_at."</div>";
$output .= "</div>\n";
}
$i++;
}
$output .= "</div>";
if ($need_cache) {
$h->smartCache('html', 'posts', 10, $output, 'twitter_widget');
}
echo $output;
}
示例2: showUser
public function showUser($Model, $param)
{
return $this->_Twitter->showUser($param);
}