twitter_stream_convert_to_xml

The Twitter Stream twitter stream convert to xml function.

Description

twitter_stream_convert_to_xml( $content ); 

Parameters (1)

0. $content
The content.

Usage

  1. if ( !function_exists( 'twitter_stream_convert_to_xml' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'twitter-stream/twitter-stream.php'; 
  3.  
  4. // The content. 
  5. $content = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = twitter_stream_convert_to_xml($content); 
  9.  

Defined (1)

The function is defined in the following location(s).

/twitter-stream.php  
  1. function twitter_stream_convert_to_xml($content) { 
  2.  
  3. //Some sort of strange fix for unterminated entities in XML. Possibly related to PHP bug #36795. 
  4. $content = str_replace('&', '&', $content); 
  5. //Convert the string recieved from twitter into a simple XML object. 
  6. $twitxml = simplexml_load_string($content); //Supress errors as we check for any next anyway. 
  7.  
  8. if($twitxml === FALSE) { 
  9. //Twitter was unable to provide the stream requested. Let's notify the user. 
  10. echo '<p>'; 
  11. _e('Your Twitter stream could not be collected. Normally this is caused by no XML feed being returned. Why this happens is still unclear.', 'twit_stream'); 
  12. echo '</p>'; 
  13. return FALSE; 
  14. if(isset($twitxml->error)) { 
  15. //Check for anerrorsuch as API overuse and display it. 
  16. echo '<p>'.$twitxml->error.'</p>'; 
  17. return FALSE; 
  18.  
  19. return $twitxml; 
  20.