Twitter api 接口类

$1', $text);
        $text = preg_replace("#(^|[\n ])@([^ \"\t\n\r<]*)#ise", "'\\1@\\2'", $text);
        $text = preg_replace("#(^|[\n ])\#([^ \"\t\n\r<]*)#ise", "'\\1#\\2'", $text);

        return $text;
    }

    /**
     * Main method to retrieve the tweets and return html for display
     *
     * @access public
     * @param $twitter_id, $num_of_tweets, $timezone
     * @return $result
     */
    public function get_tweets($twitter_id, $num_of_tweets = 3, $timezone = "PRC") {
        $include_replies = false;

        date_default_timezone_set($timezone);

// the html markup
        $cont_o = "
\n"; $tweet_o = "
\n"; $tweet_c = "
\n\n"; $detail_o = "
\n"; $detail_c = "
\n\n"; $cont_c = "
\n"; $result = $cont_o; if ($twitter_xml = $this->api_call($twitter_id, $num_of_tweets)) { foreach ($twitter_xml->status as $key => $status) { if ($include_replies == true | substr_count($status->text, "@") == 0 | strpos($status->text, "@") != 0) { $tweet = $this->process_links($status->text); $result .= $tweet_o . $tweet . $tweet_c . $detail_o . date('D jS M y H:i', strtotime($status->created_at)) . $detail_c; } } $result .= $cont_c; } else { $result .= $cont_o . $tweet_o . "Twitter seems to be unavailable at the moment." . $tweet_c . $cont_c; } return $result; } }

你可能感兴趣的:(php,开发应用)