本文整理匯總了PHP中Twitter::replace_links_in_status方法的典型用法代碼示例。如果您正苦於以下問題:PHP Twitter::replace_links_in_status方法的具體用法?PHP Twitter::replace_links_in_status怎麽用?PHP Twitter::replace_links_in_status使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Twitter
的用法示例。
在下文中一共展示了Twitter::replace_links_in_status方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: Twitter
function generate_content(&$title)
{
global $serendipity;
$hideDisplay = "#caching#" == $title;
$number = $this->get_config('number');
$service = $this->get_config('service', 'twitter.com');
$username = $this->get_config('username');
$dateformat = $this->get_config('dateformat');
$title = $this->get_config('title', $this->title);
$showformat = $this->get_config('showformat');
$cachetime = (int) $this->get_config('cachetime', 300);
if (!is_numeric($number)) {
$number = 10;
}
if ($service == 'identi.ca') {
$followme_url = 'http://identi.ca/' . $username;
$service_url = 'http://identi.ca/api';
$status_url = 'http://identi.ca/notice/';
//$JSONcallback = 'identicaCallback2';
$JSONcallback = 'twitterCallback2';
// We call the twitter widget. It is working with identi.ca too, but the callback name is twitter!
$timelineurl = 'http://identi.ca/api/statuses/user_timeline/' . $username . '.json?callback=' . $JSONcallback . '&count=' . $number;
$api = new Twitter(true);
} else {
$followme_url = 'https://twitter.com/' . $username;
$service_url = 'https://twitter.com';
$status_url = 'https://twitter.com/' . $username . '/statuses/';
$JSONcallback = 'twitterCallback2';
$timelineurl = 'https://api.twitter.com/1/statuses/user_timeline.json?screen_name=' . $username . '&count=' . $number . '&callback=' . $JSONcallback;
$api = new Twitter(false);
}
if (!$dateformat || strlen($dateformat) < 1) {
$dateformat = '%A, %B %e %Y';
}
if ($showformat == 'PHP') {
$cache_user = md5($service) . md5($username);
$cachefile = $serendipity['serendipityPath'] . PATH_SMARTY_COMPILE . "/twitterresult.{$cache_user}.json";
// If the Event Plugin is not installed, we have to fill the cachefile on our own..
// To immidiately display a result, the file_exists check is added.
if (!class_exists('serendipity_event_twitter') || !file_exists($cachefile)) {
// If we have twitter using API 1.1 the sidebarplugin *needs* the eventplugin to update
if ($this->get_config('service', 'twitter.com') == 'identi.ca' || $this->get_config('twitter_api', '1.0') == '1.0') {
$this->updateTwitterTimelineCache($cachefile);
}
}
// Get xml from cache:
if (file_exists($cachefile)) {
$xml = json_decode(unserialize(file_get_contents($cachefile)));
}
$str_output = array();
// now process it:
$str_output[] = '<ul id="twitter_update_list">';
$odd_css = 'odd';
if (!is_array($xml)) {
if (!empty($xml->error)) {
$msg = $xml->error;
} else {
$msg = PLUGIN_TWITTER_PROBLEM_TWITTER_ACCESS;
}
$str_output[] = "<li>{$msg}</li>";
} else {
if ($number > 0) {
$counter = 0;
$toall_only = serendipity_db_bool($this->get_config('toall_only', false));
$filter_all_user = serendipity_db_bool($this->get_config('filter_all_user', false));
foreach ($xml as $key => $status) {
// Change encoding of update to Visitors language
if (LANG_CHARSET != 'UTF-8' && function_exists("mb_convert_encoding")) {
$status->text = mb_convert_encoding($status->text, LANG_CHARSET, 'auto');
}
$status->text = htmlentities($status->text, ENT_QUOTES, 'UTF-8');
$showit = true;
if ($filter_all_user && preg_match('/@/', $status->text)) {
$showit = false;
} else {
if ($toall_only && preg_match('/^@/', $status->text)) {
$showit = false;
}
}
if ($showit) {
$str_output[] = '<li class="twitter_update_' . $odd_css . '"><span> ' . ($status->text = $api->replace_links_in_status($status->text, $this->get_config('linktext', 'link'), 'twitter_update_link', 'twitter_user') . '</span><a class="twitter_update_time" href="' . $status_url . $status->id_str . '">' . $this->makeDate($status->created_at, $dateformat) . '</a></li>');
$odd_css = $odd_css == 'odd' ? 'even' : 'odd';
$counter++;
}
if ($counter >= $number) {
break;
}
}
}
}
$str_output[] = '</ul>';
// Display only, if we have something meaningful:
if (!$hideDisplay && count($str_output) > 2) {
$output = implode('', $str_output);
$this->output($output);
}
} else {
if (!$hideDisplay) {
echo '<ul id="twitter_update_list"><li style="display: none"></li></ul>' . "\n";
echo '<script type="text/javascript" src="https://twitter.com/javascripts/blogger.js"></script>' . "\n";
//.........這裏部分代碼省略.........
示例2: elseif
//.........這裏部分代碼省略.........
}
}
} elseif (isset($_POST['tweeter_change_identity'])) {
$val_tweet = $_POST['tweet'];
$val_short = $_POST['shorturl'];
}
// Create strings of twitter URL length:
$this->twitter_check_config();
$http_length_str = str_repeat("=", (int) $this->get_config('twitter_config_http_len'));
$https_length_str = str_repeat("=", (int) $this->get_config('twitter_config_https_len'));
// Hide shorten url input, if no url shorter is used!
if ('raw' == $this->get_config('anounce_url_service', '7ax.de')) {
echo "<style type=\"text/css\">div#serendipity_admin_tweeter_shorturl {display: none;}</style>";
@define('PLUGIN_EVENT_TWITTER_TWEETER_SHORTEN_OR_UPDATE', PLUGIN_EVENT_TWITTER_TWEETER_UPDATE);
} else {
@define('PLUGIN_EVENT_TWITTER_TWEETER_SHORTEN_OR_UPDATE', PLUGIN_EVENT_TWITTER_TWEETER_SHORTEN . ' / ' . PLUGIN_EVENT_TWITTER_TWEETER_UPDATE);
}
// Display the form
include dirname(__FILE__) . '/tweeter/tweeter_client.inc.php';
} else {
return true;
// if disabled, don't display anything else!
}
// Display history
if ($tweeter_has_timeline) {
if ($account_type == "identica") {
$count = $this->get_config('tweeter_history_count', 10);
$api = new Twitter($account_type == 'identica');
$statuses = $api->timeline($account_name, $account_pwd, $count);
} else {
require_once dirname(__FILE__) . '/twitteroauth/twitteroauth.php';
if ($_POST['tweeter_timeline']) {
$get_connection = "statuses/" . $_POST['tweeter_timeline'];
} else {
$get_connection = "statuses/" . $this->get_config('tweeter_timeline');
}
$connection = $this->twitteroa_connect($acc_number);
$statuses = $connection->get($get_connection);
$http_code = $connection->http_code;
$api = new Twitter($account_type == 'identica');
}
$buffer = '';
if (!is_array($statuses)) {
if (empty($statuses)) {
$buffer = '<li><strong>Result from Twitter was empty.</strong><br/>Perhaps down for maintenance?</li>';
} elseif (is_object($statuses)) {
if (!empty($statuses->error)) {
$buffer = '<li><strong>' . $statuses->error . '</strong></li>';
} else {
$buffer = '<li><strong>Reported an unknown error</strong></li>';
}
} else {
print_r($statuses);
$buffer = '<li><strong>Twitter reported http error ' . $statuses . '</strong></li>';
}
} else {
if ($account_type == "twitter") {
if ($_POST['tweeter_timeline']) {
$buffer_header = PLUGIN_EVENT_TWITTER_TIMELINE . ": " . $_POST['tweeter_timeline'];
} else {
$buffer_header = PLUGIN_EVENT_TWITTER_TIMELINE . ": " . $this->get_config('tweeter_timeline');
}
}
foreach ($statuses as $status) {
// Setup links inside of the text
$status->text = $api->replace_links_in_status($status->text);
// Change encoding to blog encoding
if (LANG_CHARSET != 'UTF-8' && function_exists("mb_convert_encoding")) {
$status->text = mb_convert_encoding($status->text, LANG_CHARSET, 'UTF-8');
}
if (strtoupper($account_name) != strtoupper($status->user->screen_name)) {
$reply_link = '<a href="javascript:tweeter_reply(\'' . $status->user->screen_name . '\');" title="' . PLUGIN_EVENT_TWITTER_TWEETER_REPLY . '">@</a>';
$direct_link = '<a href="javascript:tweeter_dm(\'' . $status->user->screen_name . '\');" title="' . PLUGIN_EVENT_TWITTER_TWEETER_DM . '">DM</a>';
$retweet_link = '<a href="javascript:tweeter_retweet(\'' . $status->user->screen_name . '\', \'' . str_replace('"', '#quot2;', str_replace("'", '#quot1;', strip_tags($status->text))) . '\');" title="' . PLUGIN_EVENT_TWITTER_TWEETER_RETWEET . '">RT</a>';
} else {
$reply_link = '';
$direct_link = '';
$retweet_link = '';
}
// Twitter delivers the complete status ID in an extra field!
$status_id = $account_type == 'identica' ? $status->id : $status->id_str;
// Add each status formatted to a html buffer
$buffer .= '<li class="tweeter_line">
<div class="tweeter_profile_img">
<img src="' . $status->user->profile_image_url . '" width="48" height="48" alt="" title="' . $status->user->screen_name . '"/>
</div>
<div class="tweeter_profile_text">
<a href="' . $api->get_base_url() . $status->user->screen_name . '">' . $status->user->screen_name . '</a> ' . $status->text . '
</div>
<div class="tweeter_profile_links">
<a href="' . $api->get_status_url($status->user->screen_name, $status_id) . '">' . Twitter::create_status_ago_string($status->created_at) . '</a> from ' . $status->source . ' ' . $reply_link . ' ' . $direct_link . ' ' . $retweet_link . '
</div>
</li>';
}
}
// Display the history
include dirname(__FILE__) . '/tweeter/tweeter_history.inc.php';
$return = true;
}
}