[PHP] PHP代码片段 - Tweeter Feed Runner——使用任意twitt →→→→→进入此内容的聊天室

来自 , 2019-08-29, 写在 PHP, 查看 113 次.
URL http://www.code666.cn/view/ae1d2c2d
  1. pversion;
  2.     }
  3.     public function loadTimeline($user, $max = 20){
  4.         $this->twitURL .= 'statuses/user_timeline.xml?screen_name='.$user.'&count='.$max;
  5.         $ch        = curl_init();
  6.         curl_setopt($ch, CURLOPT_URL, $this->twitURL);
  7.         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  8.         $this->xml = curl_exec($ch);
  9.         return $this;
  10.     }
  11.     public function getTweets(){
  12.         $this->twitterArr = $this->getTimelineArray();
  13.         $tweets = array();
  14.         foreach($this->twitterArr->status as $status){
  15.             $tweets[$status->created_at->__toString()] = $status->text->__toString();
  16.         }
  17.         return $tweets;
  18.     }
  19.     public function getTimelineArray(){
  20.         return simplexml_load_string($this->xml);
  21.     }
  22.     public function formatTweet($tweet){
  23.         $tweet = preg_replace("/(http(.+?))( |$)/","$1$3", $tweet);
  24.         $tweet = preg_replace("/#(.+?)(\h|\W|$)/", "#$1$2", $tweet);
  25.         $tweet = preg_replace("/@(.+?)(\h|\W|$)/", "@$1$2", $tweet);
  26.         return $tweet;
  27.     }
  28. }

回复 "PHP代码片段 - Tweeter Feed Runner——使用任意twitt"

这儿你可以回复上面这条便签

captcha