2011-07-04 4 views
0

の内側に、私はTwitterの投稿に引き出すために、次のコードを使用していますエコー:この行でPHP - 既存の機能

<?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(); 

?> 

:$フィード=新しいTwitterFeed( 'trekradio'、4); - 「トレカディオ」を変更して、次の値にします:

<?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; }}} ?> 

どうすればいいですか?

答えて

3

私は推測している:

cimy_uef_sanitize_content(get_cimyFieldValue(1, 'twitter-username')) 

を使用、その場合は 'trekradio'

と同じです:

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

'trekradio'cimy_uef_sanitize_content(get_cimyFieldValue(1, 'twitter-username'))に置き換えます。

cimy_uef_sanitize_contentの機能に応じて、おそらくget_cimyFieldValue(1, 'twitter-username')が必要です。

関連する問題