How do I retrieve twitter xml for Flash site via php properly
        Posted  
        
            by daidai
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by daidai
        
        
        
        Published on 2010-05-18T21:36:21Z
        Indexed on 
            2010/05/18
            21:40 UTC
        
        
        Read the original article
        Hit count: 235
        
Am I using TwitterScript to retrieve Twitter data for inside a Flash site. Due to Twitter's crossdomain policy, I need to setup a php proxy... Firstly I made a simple one
<?php 
$url = $_GET['url'];
readfile($url);
?>
but I then get this error
URL file-access is disabled in the server configuration
which is only resolved by getting my host to turn fopen() on, which I don't want to do.
Then I found this
<?php
function get_content($url)
{
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_HEADER, 0);
ob_start();
curl_exec ($ch);
curl_close ($ch);
$string = ob_get_contents();
ob_end_clean();
return $string;    
}
#usage:
$url = $_GET['url'];
$content = get_content ($url);
var_dump ($content);
?>
which solves that problem but the data now is the correct XML but looks like:
string(39950) "<?xml version="1.0" encoding="UTF-8"?>
<statuses type="array">
<status>
...
</statuses>"
How do I get the XML data out of that string?
© Stack Overflow or respective owner