WordPress.org

Ready to get started?Download WordPress

Forums

Twitter Feed not working (2 posts)

  1. zockey
    Member
    Posted 1 year ago #

    Dear friends,
    I have a problem on my blog with Twitter Feed which is not working. I am not developer and I can't resolve that problem. Here is a code of Twitter Feed on my blog and if anybody can help me to resolve this I will be very grateful:

    <?php function grey_twitter_timeline( $id=NULL, $nr=5 ) {
        $feed = "http://twitter.com/statuses/public_timeline.rss";
        if($id) $feed = str_replace( "public_timeline", "user_timeline/".$id, $feed );
        $ch = curl_init($feed);
        curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch,CURLOPT_HEADER, 0);
        curl_setopt($ch,CURLOPT_USERAGENT,"GREY");
        curl_setopt($ch,CURLOPT_TIMEOUT,10);
        $data = curl_exec($ch);
        if (curl_errno($ch) !== 0 || curl_getinfo($ch, CURLINFO_HTTP_CODE) !== 200) {
            $data === false;
        }
        curl_close($ch);
        $xml = new SimpleXmlElement($data, LIBXML_NOCDATA);
        if(!$xml->error) {
            $i = 0;
            $return = "<ul class='twitter_list'>";
            foreach( $xml->channel->item as $row ) {
                if( $i<$nr ) {
                    (isset($id)) ? $title = preg_replace( "/^$id: /",'', $row->title) : $title = $row->title;
                    $title = preg_replace('@(https?://([-\w\.]+)+(:\d+)?(/([-\w/_\.]*(\?\S+)?)?)?)@', '<a href="$1">$1</a>', $title);
                    $title = preg_replace("/@(\w+)/", '<a href="http://twitter.com/$1">@$1</a>', $title);
                    $title = preg_replace("/#(\w+)/", '<a href="http://twitter.com/#search?q=$1">#$1</a>', $title);
                    $return .= "
    <li>". $title ."</li>
    ";
                }
                $i++;
            }
            update_option('grey_twitter_timeline', $return);
            return $return . "";
        } else {
            return get_option('grey_twitter_timeline');
        }
    }
    
    ?>
  2. Archie22is
    Member
    Posted 1 year ago #

    Hi,

    Here is an easier option for non-developers. It works 100%:
    http://tweet.seaofclouds.com/

Topic Closed

This topic has been closed to new replies.

About this Topic