[英]PHP - An Echo inside of an existing function
I am using the following code to pull in Twitter Posts:我正在使用以下代码拉入 Twitter 帖子:
<?php
class TwitterFeed {
public $tweets = array();
public function __construct($user, $limit = 5) {
$user = str_replace(' OR ', '%20OR%20', $user);
$feed = curl_init('http://search.twitter.com/search.atom?q=from:'. $user .'&rpp='. $limit);
curl_setopt($feed, CURLOPT_RETURNTRANSFER, true);
curl_setopt($feed, CURLOPT_HEADER, 0);
$xml = curl_exec($feed);
curl_close($feed);
$result = new SimpleXMLElement($xml);
foreach($result->entry as $entry) {
$tweet = new stdClass();
$tweet->id = (string) $entry->id;
$user = explode(' ', $entry->author->name);
$tweet->user = (string) $user[0];
$tweet->author = (string) substr($entry->author->name, strlen($user[0])+2, -1);
$tweet->title = (string) $entry->title;
$tweet->content = (string) $entry->content;
$tweet->updated = (int) strtotime($entry->updated);
$tweet->permalink = (string) $entry->link[0]->attributes()->href;
$tweet->avatar = (string) $entry->link[1]->attributes()->href;
array_push($this->tweets, $tweet);
}
unset($feed, $xml, $result, $tweet);
}
public function getTweets() { return $this->tweets; }
}
$feed = new TwitterFeed('trekradio', 4);
$tweets = $feed->getTweets();
?>
On this line: $feed = new TwitterFeed('trekradio', 4);在这一行: $feed = new TwitterFeed('trekradio', 4); - I want to change "trekradio" so it pulls in the following value: - 我想更改“trekradio”,以便它引入以下值:
<?php if (have_posts()) { $flag = true; while (have_posts()) { the_post();
if ($flag) { $value = get_cimyFieldValue(get_the_author_ID(), 'twitter-username');
if ($value != NULL) echo "<p><strong>Twitter: </strong> You can follow me on Twitter by <a href=\"http://www.twitter.com/" . cimy_uef_sanitize_content($value) . "\">clicking here!</a></p>";
$flag = false; }}} ?>
How can I do this?我怎样才能做到这一点?
I'm guessing that:我猜是这样的:
cimy_uef_sanitize_content(get_cimyFieldValue(1, 'twitter-username'))
is the same as 'trekradio'与“trekradio”相同
If so, use:如果是这样,请使用:
$feed = new TwitterFeed(cimy_uef_sanitize_content(get_cimyFieldValue(1, 'twitter-username')), 4);
Replace 'trekradio'
with cimy_uef_sanitize_content(get_cimyFieldValue(1, 'twitter-username'))
.将'trekradio'
替换为cimy_uef_sanitize_content(get_cimyFieldValue(1, 'twitter-username'))
。
Depending on what the cimy_uef_sanitize_content
function is doing, maybe you just need get_cimyFieldValue(1, 'twitter-username')
.根据cimy_uef_sanitize_content
function 正在做什么,也许您只需要get_cimyFieldValue(1, 'twitter-username')
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.