Twitter Feed not working
-
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 = "https://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="https://twitter.com/$1">@$1</a>', $title); $title = preg_replace("/#(\w+)/", '<a href="https://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'); } } ?>
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Twitter Feed not working’ is closed to new replies.