Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/226.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP-现有函数内部的回音_Php_Wordpress_Twitter - Fatal编程技术网

PHP-现有函数内部的回音

PHP-现有函数内部的回音,php,wordpress,twitter,Php,Wordpress,Twitter,我使用以下代码来获取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.

我使用以下代码来获取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();

?>

在这行:$feed=newtwitterfeed('trekradio',4);-我想更改“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;    }}} ?>


我该怎么做?

cimy\u uef\u sanitize\u内容替换
'trekradio'
(获取cimyFieldValue(1,'twitter用户名'))


根据
cimy\u uef\u sanitize\u content
函数的作用,您可能只需要
get\u cimyFieldValue(1,'twitter username')
'trekradio'
替换为
cimy\u uef\u sanitize\u content(get\u cimyFieldValue(1,'twitter username')

根据
cimy\u uef\u sanitize\u content
函数的作用,您可能只需要
get\u cimyFieldValue(1,'twitter username')
我猜:

cimy_uef_sanitize_content(get_cimyFieldValue(1, 'twitter-username'))
与“trekradio”相同

如果是,请使用:

$feed = new TwitterFeed(cimy_uef_sanitize_content(get_cimyFieldValue(1, 'twitter-username')), 4);
我猜:

cimy_uef_sanitize_content(get_cimyFieldValue(1, 'twitter-username'))
与“trekradio”相同

如果是,请使用:

$feed = new TwitterFeed(cimy_uef_sanitize_content(get_cimyFieldValue(1, 'twitter-username')), 4);